最近 Open Interpreterの記事をいろいろ見つけたので自分のMacにもインストールしようとしてみたところ、以下のようなエラーが出ました。
エラーが大量発生
% pip install open-interpreter
ERROR: Ignored the following versions that require a different python version: 0.0.1 Requires-Python >=3.10,<4.0; 0.0.2 Requires-Python >=3.10,<4.0; 0.0.21 Requires-Python >=3.10,<4.0; 0.0.22 Requires-Python >=3.10,<4.0; 0.0.221 ・・・
・・・
Requires-Python >=3.10,<4.0; 0.1.4 Requires-Python >=3.10,<4.0
ERROR: Could not find a version that satisfies the requirement open-interpreter (from versions: none)
ERROR: No matching distribution found for open-interpreter
% python --version
Python 3.8.3
% pyenv install -list
Available versions:
・・・
3.10.0
3.10-dev
3.11-dev
・・・
stackless-3.7.5
% pyenv install 3.10.0
python-build: use openssl@1.1 from homebrew
・・・
Installed Python-3.10.0 to /・・・/.pyenv/versions/3.10.0
% pyenv local 3.10.0
% Python -V
Python 3.10.0
% pip install open-interpreter
Collecting open-interpreter
Downloading open_interpreter-0.1.4-py3-none-any.whl (35 kB)
・・・
WARNING: You are using pip version 21.2.3; however, version 23.2.1 is available.
You should consider upgrading via the '/Users/katsuhiro.kurita/.pyenv/versions/3.10.0/bin/python3.10 -m pip install --upgrade pip' command.
mermaid live editorはオンラインにてフリーで利用でき、アカウントも作成する必要がないので、誰でも自由に Markdown形式の記述からシーケンス図を作成できてしまいます。
mermaid live editor
https://mermaid-js.github.io/mermaid-live-editor/edit
2.Markdown形式でシーケンスを作成
Markdown形式ってなんだか難しそうに聞こえますが、意外と簡単です。
初めて作成した私でも下記の記述程度であれば、見よう見までで30分〜1時間程度でかけてしまいました。
sequenceDiagram ← シーケンズ図であることを宣言
Ar->>Xs: data ← ArからXsにメッセージ(data)を渡す場合はこう書く
Note right of Ar: IoC etc ← 黄色い付箋にノートが書ける
Xs->>Xs: data check
alt C2 ← 条件分岐を記載
Xs ->> Xs: transparent check;
alt blocked
Xs->>Xs: write down
else passed
Xs->>So: investigation request
end
else phishing
Xs ->> Xs: transparent check
alt blocked
Xs->>Xs: write down
else passed
Xs->>So: investigation request
end
else others
Xs ->> Vi: evaluation check
Vi ->> Xs: result
Xs ->> Xs: result check
alt benign
Xs ->> Xs: write down
else malignant
Xs ->> So: investigation request
end
end
Xs ->> Ar:investigation result
So ->> So:investiogate
So ->> Cs:investigation result
So ->> Ar:investigation result
Cs ->> Cs:traffic number check
alt over N
Cs ->> Si: white regist
else under N
Cs ->> Cs: block request
end
Cs ->> Ar: result
3.できあがったシーケンス図を確認
mermaid live editorの左ペインで、2.に掲載したMarkdown形式のシーケンスを書いていると、右ペインにリアルタイムでシーケンス図が描かれます。
これはおもった以上に便利ですね。
mermaid live editor
いきなりPower Point でこのシーケンス図を描こうとするとかなり難儀ですが、一旦、mermaid live editorで作成しておいて、後で Power Point で清書するという使い方もありかと思います。
sequenceDiagram
Ar->>Xs: data
Note right of Ar: IoC etc
alt C2
Xs->>Xs: write down
else phishing
Xs ->> Xs: transparent check
Xs->>Xs: write down
else others
Xs ->> Vi: evaluation check
Vi ->> Xs: result
Xs ->> Xs: result check
end
Xs ->> So:investigation request
Xs ->> Ar:investigation result
So ->> So:investiogate
So ->> Cs:investigation result
So ->> Ar:investigation result
Cs ->> Cs:remediation dicision
alt benign
Cs ->> Cs: block request
else malignant
Cs ->> So: quarantine request
Cs ->> As: quarantine report
So ->> So: quarantine execute
So ->> Ci: quarantine fin report
As ->> Cs: status report
end
Cs ->> Ar: result
from requests.exceptions import Timeout
・・・
# Get the HTML content of the top page
try:
response = requests.get(url, timeout=(6.0, 10.0))
html = response.content.decode("utf-8")
except Timeout:
print(f"\n[Timeout {url}]")
% bandit test.py
[main] INFO profile include tests: None
[main] INFO profile exclude tests: None
[main] INFO cli include tests: None
[main] INFO cli exclude tests: None
[main] INFO running on Python 3.8.3
[node_visitor] WARNING Unable to find qualified name for module: test.py
Run started:2023-08-14 08:04:48.814175
Test results:
No issues identified.
Code scanned:
Total lines of code: 53
Total lines skipped (#nosec): 0
Run metrics:
Total issues (by severity):
Undefined: 0
Low: 0
Medium: 0
High: 0
Total issues (by confidence):
Undefined: 0
Low: 0
Medium: 0
High: 0
Files skipped (0):
%
% bandit test.py
[main] INFO profile include tests: None
[main] INFO profile exclude tests: None
[main] INFO cli include tests: None
[main] INFO cli exclude tests: None
[main] INFO running on Python 3.8.3
[node_visitor] WARNING Unable to find qualified name for module: test.py
Run started:2023-08-14 01:37:45.050500
Test results:
>> Issue: [B113:request_without_timeout] Requests call without timeout
Severity: Medium Confidence: Low
CWE: CWE-400 (https://cwe.mitre.org/data/definitions/400.html)
More Info: https://bandit.readthedocs.io/en/1.7.5/plugins/b113_request_without_timeout.html
Location: test.py:31:11
30 # Get the HTML content of the top page
31 response = requests.get(url)
32 html = response.content.decode("utf-8")
--------------------------------------------------
>> Issue: [B113:request_without_timeout] Requests call without timeout
Severity: Medium Confidence: Low
CWE: CWE-400 (https://cwe.mitre.org/data/definitions/400.html)
More Info: https://bandit.readthedocs.io/en/1.7.5/plugins/b113_request_without_timeout.html
Location: test.py:62:15
61
62 response = requests.get(link)
63 html = response.content.decode("utf-8")
--------------------------------------------------
Code scanned:
Total lines of code: 46
Total lines skipped (#nosec): 0
Run metrics:
Total issues (by severity):
Undefined: 0
Low: 0
Medium: 2
High: 0
Total issues (by confidence):
Undefined: 0
Low: 2
Medium: 0
High: 0
Files skipped (0):
%
3.bandit 実行結果の考察
どうやら「Test results:」という部分にプログラムの問題点が列挙されているようです。
2つ「Issue」が記載されていますが、どちらも Requests call without timeout となっています。
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.