Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#175 ごく稀にログが欠損する可能性を排除できない問題を修正 #183

Merged
merged 8 commits into from
Mar 22, 2024

Conversation

tkhr-ueda
Copy link
Contributor

close #175

実装内容

既存コードの修正

下記のコードを、集約対象のログファイルのリストを変数に格納した後、集約処理や削除処理を実行する際に当該変数を参照するように変更。

awk '$9<60{print}' $(find /usr/local/zeek/logs -name "conn.*.log") > "/usr/local/zeek/logs/conn_replace.log"
rm $(find /usr/local/zeek/logs -name "conn.*.log")

cat /var/log/p0f-k.log.* > p0f-k.log
chmod 644 p0f-k.log
rm /var/log/p0f-k.log.*

cat /var/log/suricata/eve?*.json > $4/eve.json
rm /var/log/suricata/eve?*.json

merge_log () {
cat $1 > $2
sed -i '/^#/d' $2
sed -i '1i #ts start-time end-time duration rtt proto sip sp dip dp srcMacAddress destMacAddress iflags uflags riflags ruflags isn risn tag rtag pktoct rpkt roct end-reason' $2
}
cd $1/$2 || exit
flow=$(find "/var/log/yaf" -name "flow*.yaf")
for flowfile in $flow; do
/usr/local/bin/yafscii --tabular --print-header --mac --in $flowfile --out flow.csv
cat flow.csv | /opt/ot_tools/yaf.awk > "$flowfile".log
rm "$flowfile" flow.csv
done
merge_log "/var/log/yaf/flow*.log" "yaf_flow.log"
rm /var/log/yaf/flow*.log

テストコードの追加

今回修正したスクリプトが動作することを確認するためのテストコードを追加。

OsecT$ cd osect_sensor                # osect_sensorディレクトリへ移動
OsecT/osect_sensor$ ./run_sh_test.sh  # テストコードを実行

@tkhr-ueda tkhr-ueda self-assigned this Mar 21, 2024
@tkhr-ueda tkhr-ueda marked this pull request as ready for review March 22, 2024 01:41
@nbhgytzheng nbhgytzheng merged commit f5c86e4 into main Mar 22, 2024
6 checks passed
@nbhgytzheng nbhgytzheng deleted the bug-#175 branch March 22, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ごく稀にログが欠損する可能性を排除できない問題を修正
2 participants