Skip to content

Commit 00f9dfd

Browse files
committed
remove empty file, rename out to log file, add stub python datasets folder validation code
1 parent c57ecba commit 00f9dfd

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

.github/validate_dataset_ymls.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import datetime
2+
import pathlib
3+
import sys
4+
from enum import StrEnum, auto
5+
from uuid import UUID
6+
7+
from pydantic import BaseModel, Field, HttpUrl
8+
9+
10+
class Environment(StrEnum):
11+
attack_range = auto()
12+
13+
14+
class AttackDataYml(BaseModel):
15+
author: str = Field(..., min_length=5)
16+
id: UUID
17+
date: datetime.date
18+
description: str = Field(..., min_length=5)
19+
environment: Environment
20+
dataset: list[HttpUrl] = Field(..., min_length=1)
21+
sourcetypes: list[str] = Field(..., min_length=1)
22+
references: list[HttpUrl] = Field(..., min_length=1)
23+
24+
25+
# Get all of the yml files in the datasets folder
26+
datasets_root = pathlib.Path("datasets/")
27+
28+
29+
# We only permit certain filetypes to be present in this directory.
30+
# This is to avoid the inclusion of unsupported file types and to
31+
# assist in the validation of the YML files
32+
ALLOWED_SUFFIXES = [".yml", ".log", ".json"]
33+
SPECIAL_GIT_GILES = ".gitkeep"
34+
bad_files = [
35+
name
36+
for name in datasets_root.glob(r"**/*.*")
37+
if name.is_file()
38+
and not (name.suffix in ALLOWED_SUFFIXES or name.name == SPECIAL_GIT_GILES)
39+
]
40+
41+
if len(bad_files) > 0:
42+
print(
43+
f"Error, the following files were found in the {datasets_root} folder. Only files ending in {ALLOWED_SUFFIXES} or {SPECIAL_GIT_GILES} are allowed:"
44+
)
45+
print("\n".join([str(f) for f in bad_files]))
46+
sys.exit(1)

datasets/attack_techniques/T1003.003/atomic_red_team/windows-sec-events.out renamed to datasets/attack_techniques/T1003.003/atomic_red_team/windows-sec-events.log

File renamed without changes.

datasets/attack_techniques/T1499/splunk/.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)