SIABench commited on
Commit
842c470
·
verified ·
1 Parent(s): 3dee21e

Delete SIA_Dataset.py

Browse files
Files changed (1) hide show
  1. SIA_Dataset.py +0 -193
SIA_Dataset.py DELETED
@@ -1,193 +0,0 @@
1
- """
2
- SIABench — Custom Dataset Loading Script
3
- Place this file at the ROOT of the HuggingFace repo as SIA_Dataset.py
4
- """
5
-
6
- import json
7
- import os
8
- import datasets
9
-
10
- _DESCRIPTION = """
11
- SIABench is a benchmark for evaluating LLMs on cybersecurity incident analysis tasks.
12
- It contains three sub-datasets:
13
- - alert_triaging_tii: 100 alert triaging scenarios from TII-SSRC-23 (50 TP, 50 FP)
14
- - alert_triaging_cic: Alert triaging scenarios from CIC datasets
15
- - sia_dataset: 23 open-ended CTF network forensics scenarios
16
- """
17
-
18
- _CITATION = """
19
- @inproceedings{siabench2025,
20
- title={SIABENCH: A Benchmark for Evaluating LLMs on Cybersecurity Incident Analysis},
21
- author={Jajodia, Sourov and others},
22
- booktitle={PST 2025},
23
- year={2025}
24
- }
25
- """
26
-
27
- _BASE = "SIABench-main"
28
-
29
-
30
- class SIABenchConfig(datasets.BuilderConfig):
31
- def __init__(self, data_dirs, **kwargs):
32
- super().__init__(**kwargs)
33
- self.data_dirs = data_dirs # list of (split_name, folder_path) tuples
34
-
35
-
36
- class SIABench(datasets.GeneratorBasedBuilder):
37
-
38
- BUILDER_CONFIGS = [
39
-
40
- # ── Alert Triaging TII ──────────────────────────────────────────
41
- SIABenchConfig(
42
- name="alert_triaging_tii",
43
- description="Alert triaging scenarios derived from TII-SSRC-23 dataset.",
44
- data_dirs=[
45
- ("tp", os.path.join(_BASE, "Alert_Triaging_Dataset_TII", "TP")),
46
- ("fp", os.path.join(_BASE, "Alert_Triaging_Dataset_TII", "FP")),
47
- ],
48
- ),
49
-
50
- # ── Alert Triaging CIC ──────────────────────────────────────────
51
- SIABenchConfig(
52
- name="alert_triaging_cic",
53
- description="Alert triaging scenarios derived from CIC datasets.",
54
- data_dirs=[
55
- ("tp", os.path.join(_BASE, "Alert_Triaging_Dataset_CIC", "TP")),
56
- ("fp", os.path.join(_BASE, "Alert_Triaging_Dataset_CIC", "FP")),
57
- ],
58
- ),
59
-
60
- # ── SIA Dataset (CTF scenarios) ─────────────────────────────────
61
- SIABenchConfig(
62
- name="sia_dataset",
63
- description="Open-ended CTF network forensics scenarios from CyberDefenders and BTLO.",
64
- data_dirs=[
65
- ("train", os.path.join(_BASE, "SIA_Dataset")),
66
- ],
67
- ),
68
- ]
69
-
70
- DEFAULT_CONFIG_NAME = "sia_dataset"
71
-
72
- def _info(self):
73
- if self.config.name in ("alert_triaging_tii", "alert_triaging_cic"):
74
- features = datasets.Features({
75
- "scenario_name": datasets.Value("string"),
76
- "alert_name": datasets.Value("string"),
77
- "alert_type": datasets.Value("string"),
78
- "scenario": datasets.Value("string"),
79
- "alert": datasets.Value("string"),
80
- "tools_available": datasets.Sequence(datasets.Value("string")),
81
- "files_available": datasets.Value("string"),
82
- "instructions": datasets.Value("string"),
83
- "directory": datasets.Value("string"),
84
- "questions": datasets.Sequence({
85
- "question": datasets.Value("string"),
86
- "answer": datasets.Value("string"),
87
- }),
88
- })
89
- else: # sia_dataset
90
- features = datasets.Features({
91
- "scenario_name": datasets.Value("string"),
92
- "source": datasets.Value("string"),
93
- "last_accessed": datasets.Value("string"),
94
- "writeup": datasets.Value("string"),
95
- "scenario": datasets.Value("string"),
96
- "task_category": datasets.Value("string"),
97
- "complexity": datasets.Value("string"),
98
- "tools_available": datasets.Sequence(datasets.Value("string")),
99
- "files_available": datasets.Value("string"),
100
- "instructions": datasets.Value("string"),
101
- "directory": datasets.Value("string"),
102
- "questions": datasets.Sequence({
103
- "question": datasets.Value("string"),
104
- "answer": datasets.Value("string"),
105
- "adversarial_tactic": datasets.Value("string"),
106
- }),
107
- })
108
-
109
- return datasets.DatasetInfo(
110
- description=_DESCRIPTION,
111
- features=features,
112
- citation=_CITATION,
113
- license="Apache-2.0",
114
- )
115
-
116
- def _split_generators(self, dl_manager):
117
- return [
118
- datasets.SplitGenerator(
119
- name=split_name,
120
- gen_kwargs={"folder": folder},
121
- )
122
- for split_name, folder in self.config.data_dirs
123
- ]
124
-
125
- def _generate_examples(self, folder):
126
- if not os.path.exists(folder):
127
- return
128
-
129
- for fname in sorted(os.listdir(folder)):
130
- if not fname.endswith(".json"):
131
- continue
132
-
133
- fpath = os.path.join(folder, fname)
134
- with open(fpath, "r", encoding="utf-8") as f:
135
- data = json.load(f)
136
-
137
- scenarios = data.get("scenarios", [])
138
-
139
- # ── Extract metadata block ──
140
- meta = next(
141
- (s.get("metadata") or {} for s in scenarios if "metadata" in s),
142
- {}
143
- )
144
- # ── Extract sia_components block ──
145
- comp = next(
146
- (s.get("sia_components") or {} for s in scenarios if "sia_components" in s),
147
- {}
148
- )
149
-
150
- if self.config.name in ("alert_triaging_tii", "alert_triaging_cic"):
151
- questions = [
152
- {
153
- "question": q.get("question", ""),
154
- "answer": q.get("answer", ""),
155
- }
156
- for q in comp.get("questions", [])
157
- ]
158
- yield fname, {
159
- "scenario_name": meta.get("scenario_name", ""),
160
- "alert_name": meta.get("alert_name", ""),
161
- "alert_type": meta.get("alert_type", ""),
162
- "scenario": comp.get("scenario", ""),
163
- "alert": comp.get("alert", ""),
164
- "tools_available": comp.get("tools_available", []),
165
- "files_available": comp.get("files_available", ""),
166
- "instructions": comp.get("instructions", ""),
167
- "directory": comp.get("directory", ""),
168
- "questions": questions,
169
- }
170
-
171
- else: # sia_dataset
172
- questions = [
173
- {
174
- "question": q.get("question", ""),
175
- "answer": q.get("answer", ""),
176
- "adversarial_tactic": q.get("adversarial_tactic", ""),
177
- }
178
- for q in comp.get("questions", [])
179
- ]
180
- yield fname, {
181
- "scenario_name": meta.get("scenario_name", ""),
182
- "source": meta.get("source", ""),
183
- "last_accessed": meta.get("last_accessed", ""),
184
- "writeup": meta.get("writeup", ""),
185
- "scenario": comp.get("scenario", ""),
186
- "task_category": comp.get("task_category", ""),
187
- "complexity": comp.get("complexity", ""),
188
- "tools_available": comp.get("tools_available", []),
189
- "files_available": comp.get("files_available", ""),
190
- "instructions": comp.get("instructions", ""),
191
- "directory": comp.get("directory", ""),
192
- "questions": questions,
193
- }