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

センサー一体型OsecTのファイル転送をHTTPからMVへ変換する実装 #195

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions osect_sensor/Application/edge_cron/common/common_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LABEL_ID = ""
""" 複数スイッチ対応用のラベルID """
""" せんさー一体型である場合はラベルネームを入力 """

PCAP_UPLOADING_FILE_PATH = "paper/sc_src/input/pcap/uploading/"
"""pcapのアップロード先の配置パス"""
Expand All @@ -19,6 +20,9 @@
PCAP_SERVER_UPLOADING_FILE_PATH = "paper/sc_src/input/pcap/server_uploading/"
""" ログ解析が終わったディレクトリをuploadするための一時領域 """

PCAP_SERVER_UPLOADED_FILE_PATH = "paper/sc_src/input/pcap/server_uploaded"
""" センサー一体型のコアのアップロード先 """

SURICATA_ENABLE = True
""" SURICATA使用フラグ(リアルタイム処理の場合はログを転送) """

Expand Down Expand Up @@ -89,3 +93,6 @@

IS_CLOSED_NETWORK = True
""" モバイル経由のフラグ """

SENSOR_INTEGRATED_TYPE = False
""" センサー一体型のフラグ """
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
LABEL_ID,
CLIENT_CERTIFICATE_PATH,
IS_CLOSED_NETWORK,
SENSOR_INTEGRATED_TYPE,
PCAP_SERVER_UPLOADED_FILE_PATH,
)

# from common.common_function import pcap2log
Expand Down Expand Up @@ -164,7 +166,10 @@ def handle(self, *args, **options):
)
else:
# ログ送信
send_server(tar_list)
if SENSOR_INTEGRATED_TYPE:
move_server(tar_list)
else:
send_server(tar_list)
except Exception as e:
logger.error("can not send compressed file. " + str(e))

Expand Down Expand Up @@ -405,3 +410,18 @@ def send_server(zip_list):
logger.info("send compressed file: " + file_name)
# ファイルが正常に送信できた場合は、tar.zstファイルを削除する
os.remove(zip_file)


def move_server(zip_list):
"""
ログファイルをサーバーに送付する。
:param zip_list: 送付対象のtar.zstファイルのlist
"""

for zip_file in zip_list:
file_name = os.path.basename(zip_file)
move_path = os.path.join(PCAP_SERVER_UPLOADED_FILE_PATH, LABEL_ID)
os.makedirs(move_path, exist_ok=True)
shutil.move(zip_file, move_path)

logger.info("send compressed file: " + file_name)
50 changes: 50 additions & 0 deletions osect_sensor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,56 @@ $ vi docker-compose.yml
(削除)
```

センサー一体型OsecTの場合は以下の設定をします。

```bash
$ vi Application/edge_cron/common/common_config.py
```

変更箇所:

```python
# センサー一体型のフラグ False
SENSOR_INTEGRATED_TYPE = False
# センサー一体型のフラグ True
SENSOR_INTEGRATED_TYPE = True
```

設定ファイル:

```bash
$ vi docker-compose.yml
```

変更箇所:

```yml
volumes:
...
...
- ./conf/local.zeek:/usr/local/zeek/share/zeek/site/local.zeek # zeek realtime
volumes:
...
...
- ./conf/local.zeek:/usr/local/zeek/share/zeek/site/local.zeek # zeek realtime
- ~/edgesec_on_docker/logs/pcap/uploaded:/opt/edge_cron/paper/sc_src/input/pcap/server_uploaded # multiport
```

(参考)

センサー一体型OsecTである場合の```Application/edge_cron/common/common_config.py```の```LABEL_ID```設定は```label_name```を設定することです。

```
common_db=# select * from label_master;
id | label_id | label_name | label_display_name
----+----------+------------+--------------------
1 | sensor1(ここを指定するではなく) | default(ここを指定する) | デフォルト
2 | sensor2(ここを指定するではなく) | sensor_1(ここを指定する) | センサー1
(2 rows)
```

## 4. コンテナの構築・起動

コンテナを構築、起動します。
Expand Down