Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR の目的
機能概要
実行手順
をクローンする。
を実行する。
url: ThreatconnectomeのAPI BASE URL
-v: vulnrichmentルートディレクトリのパス
-t: Threatconnectome APIのrefresh token
※-tオプションの代わりに環境変数THREATCONNECTOME_REFRESHTOKENでも指定可能
正常実行時、1件のTopic更新毎に下記のようなデータを出力する。
出力件数が多いため、出力結果をファイル出力することを推奨する。
Success put topic. topic_id:d227c61c-bf82-42a1-b57b-b9735ce8550c cve_id:CVE-2020-5245 data: {'exploitation': 'public_poc', 'automatable': 'no'}
実行例)
cd ~/work/threatconnectome/scripts
pipenv shell
pipenv sync --dev
export THREATCONNECTOME_REFRESHTOKEN=<実際のrefresh tokenを指定>
python3 vulnrichment2tc.py -v ~/work/vulnrichment "http://localhost/api" > ../../log.txt
経緯・意図・意思決定
Topicが40524件、HITするCVEデータが3996件のローカル環境で実行時間が約24分かかった。
処理時間を分析した結果、1件あたりの処理時間は小さく件数が多いのが原因であり、大きく改善するのは困難と判断した。
vulnrichmentから全CVEファイルを読み込みメモリに保持する処理
約2秒
TC API get /topics/search
CVEデータ 28383件
1件 0.04秒
→約16分
TC API put /topics/{topic_id}
CVEデータがTopicとHITした件数 3996件
1件 0.08秒
→約5分