Skip to content

Commit 647913d

Browse files
committed
[client] feat(SCV): add domains management on contract creations (#4266)
1 parent 836aa73 commit 647913d

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

pyoaev/contracts/contract_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ class ContractConfig:
119119
color_dark: str
120120
color_light: str
121121

122+
@dataclass
123+
class Domain:
124+
domain_id: str
125+
domain_name: str
126+
domain_color: str
127+
domain_created_at: str
128+
domain_updated_at: str
122129

123130
@dataclass
124131
class Contract:
@@ -141,6 +148,7 @@ class Contract:
141148
is_atomic_testing: bool = True
142149
platforms: List[str] = field(default_factory=list)
143150
external_id: str = None
151+
domains: List[Domain] = None
144152

145153
def add_attack_pattern(self, var: str):
146154
self.contract_attack_patterns_external_ids.append(var)
@@ -163,6 +171,7 @@ def to_contract_add_input(self, source_id: str):
163171
"contract_content": json.dumps(self, cls=utils.EnhancedJSONEncoder),
164172
"is_atomic_testing": self.is_atomic_testing,
165173
"contract_platforms": self.platforms,
174+
"contract_domains": self.domains,
166175
}
167176

168177
def to_contract_update_input(self):
@@ -174,6 +183,7 @@ def to_contract_update_input(self):
174183
"contract_content": json.dumps(self, cls=utils.EnhancedJSONEncoder),
175184
"is_atomic_testing": self.is_atomic_testing,
176185
"contract_platforms": self.platforms,
186+
"contract_domains": self.domains,
177187
}
178188

179189

@@ -203,6 +213,7 @@ def prepare_contracts(contracts):
203213
"contract_attack_patterns_external_ids": c.contract_attack_patterns_external_ids,
204214
"contract_content": json.dumps(c, cls=utils.EnhancedJSONEncoder),
205215
"contract_platforms": c.platforms,
216+
"contract_domains": c.domains,
206217
},
207218
contracts,
208219
)

pyoaev/security_domain/__init__.py

Whitespace-only changes.

pyoaev/security_domain/builder.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from pyoaev.security_domain.types import SecurityDomainsKeyWords, SecurityDomains
2+
3+
class SecurityDomainBuilder:
4+
5+
def _find_in_keywords(self, keywords, search):
6+
return any(keyword.lower() in search.lower() for keyword in keywords.value)
7+
8+
# Define the domain by item
9+
def get_associated_security_domains(self, name, description):
10+
domains = []
11+
12+
if self._find_in_keywords(SecurityDomainsKeyWords.ENDPOINT, name) or self._find_in_keywords(SecurityDomainsKeyWords.ENDPOINT, description):
13+
domains.append(SecurityDomains.ENDPOINT.value)
14+
if self._find_in_keywords(SecurityDomainsKeyWords.NETWORK, name) or self._find_in_keywords(SecurityDomainsKeyWords.NETWORK, description):
15+
domains.append(SecurityDomains.NETWORK.value)
16+
if self._find_in_keywords(SecurityDomainsKeyWords.WEB_APP, name) or self._find_in_keywords(SecurityDomainsKeyWords.WEB_APP, description):
17+
domains.append(SecurityDomains.WEB_APP.value)
18+
if self._find_in_keywords(SecurityDomainsKeyWords.EMAIL_INFILTRATION, name) or self._find_in_keywords(SecurityDomainsKeyWords.EMAIL_INFILTRATION, description):
19+
domains.append(SecurityDomains.EMAIL_INFILTRATION.value)
20+
if self._find_in_keywords(SecurityDomainsKeyWords.DATA_EXFILTRATION, name) or self._find_in_keywords(SecurityDomainsKeyWords.DATA_EXFILTRATION, description):
21+
domains.append(SecurityDomains.DATA_EXFILTRATION.value)
22+
if self._find_in_keywords(SecurityDomainsKeyWords.URL_FILTERING, name) or self._find_in_keywords(SecurityDomainsKeyWords.URL_FILTERING, description):
23+
domains.append(SecurityDomains.URL_FILTERING.value)
24+
if self._find_in_keywords(SecurityDomainsKeyWords.CLOUD, name) or self._find_in_keywords(SecurityDomainsKeyWords.CLOUD, description):
25+
domains.append(SecurityDomains.CLOUD.value)
26+
27+
if 0 == len(domains):
28+
domains.append(SecurityDomains.ENDPOINT.value)
29+
30+
return domains

pyoaev/security_domain/types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from enum import Enum
2+
3+
class SecurityDomainsKeyWords(Enum):
4+
ENDPOINT = ["lsass", "registry", "dll injection", "kernel", "winlogon", "scheduled task", "wmi", "powershell", "process injection", "privilege escalation", "credential dumping", "rootkit", "startup folder", "service", "bits jobs", "removable media", "hardware additions", "browser extension", "firmware", "bootkit", "master boot record", "clipboard", "screen capture", "audio capture", "video capture", "disk wipe", "ransomware", "debugger evasion", "sandbox evasion", "trusted developer", "xsl script", "reflective code", "access token", "system binary proxy", "local"]
5+
NETWORK = ["lateral movement", "packet sniff", "port scan", "man-in-the-middle", "arp spoof", "smb", "rdp", "dns tunnel", "network share", "c2", "beacon", "proxy", "firewall", "tcp", "domain controller", "kerberos", "golden ticket", "silver ticket", "domain trust", "active directory", "ldap", "ldap", "netbios", "network boundary", "bgp hijack", "bgp hijack", "dns hijack", "dhcp poison", "forced authentication", "remote service", "network device", "vlan hopping", "protocol tunnel", "traffic signaling", "weaken encryption", "exploitation remote", "network"]
6+
WEB_APP = ["web shell", "csrf", "file upload vulnerability", "apache", "nginx", "iis", "php", "javascript", "rest api", "http", "cookie", "server-side request forgery", "ssrf", "xml external entity", "xxe", "deserialization", "path traversal", "local file inclusion", "remote file inclusion", "template injection", "ssti", "api abuse", "drive-by compromise", "browser exploit", "forge web credential", "web service", "defacement", "server software component", "reverse proxy", "cgi", "webdav", "session hijack", "web server"]
7+
EMAIL_INFILTRATION = ["spearphishing attachment", "spearphishing link", "phishing", "malicious attachment", "email account", "outlook", "exchange", "smtp", "mail server", "macro", "spoofing", "social engineering", "inbox rule", "dkim", "business email compromise", "bec", "email forwarding rule", "email delegation", "oauth consent", "reply-to manipulation", "email thread hijack", "internal spearphishing", "email collection", "zimbra", "mail client", "mapi", "email template", "spoof sender", "dmarc", "spf", "email gateway", "office document", "pdf attachment", "link shortener", "attachment"]
8+
DATA_EXFILTRATION = ["exfiltrat", "data staging", "data compressed", "steganography", "covert channel", "database dump", "automated collection", "sensitive data", "intellectual property", "data transfer", "steal", "archive", "cloud storage exfil", "ftp exfil", "physical medium", "air gap", "qr code", "scheduled transfer", "size limit", "chunk data", "alternate protocol", "icmp tunnel", "dns exfiltration", "automated exfiltration", "web service exfil", "pastebin", "code repository", "cloud account transfer", "email exfil", "data destruction", "data encrypted", "base64", "hex encode", "image steganography", "upload"]
9+
URL_FILTERING = ["domain fronting", "url shorten", "typosquatting", "typosquatting", "homograph", "punycode", "url reputation", "content filter", "web gateway", "safe browsing", "url categorization", "blacklist bypass", "whitelist", "redirect", "proxy bypass", "dns over https", "doh", "dns over tls", "dot", "unicode domain", "url encode", "double encode", "open redirect", "referrer spoof", "user agent spoof", "captive portal", "proxy pac", "socks proxy", "tor", "vpn bypass", "domain generation", "fast flux", "url confusion", "subdomain takeover", "url"]
10+
CLOUD = ["aws", "azure", "gcp", "lambda", "s3 bucket", "blob storage", "kubernetes", "docker", "serverless", "cloud instance", "iam role", "iam role", "saas", "tenant", "subscription", "api gateway", "microservice", "container", "cloud trail", "cloudtrail", "cloud formation", "terraform", "cloud init", "metadata service", "instance metadata", "cloud api", "resource policy", "cloud dashboard", "unused region", "snapshot", "cloud backup", "object storage", "cloud function", "service principal", "managed identity", "cloud key", "sas token", "assume role", "virtual machine"]
11+
12+
class SecurityDomains(Enum):
13+
ENDPOINT = { "domain_name": "Endpoint", "domain_color": "#389CFF" }
14+
NETWORK = { "domain_name": "Network", "domain_color": "#009933" }
15+
WEB_APP = { "domain_name": "Web App", "domain_color": "#FF9933" }
16+
EMAIL_INFILTRATION = { "domain_name": "E-mail Infiltration", "domain_color": "#FF6666" }
17+
DATA_EXFILTRATION = { "domain_name": "Data Exfiltration", "domain_color": "#9933CC" }
18+
URL_FILTERING = { "domain_name": "Url Filtering", "domain_color": "#66CCFF" }
19+
CLOUD = { "domain_name": "Cloud", "domain_color": "#9999CC" }
20+
TABLE_TOP = { "domain_name": "Table Top", "domain_color": "#FFCC33" }
21+
UNCLASSIFIED = { "domain_name": "Unclassified", "domain_color": "#969696" }

0 commit comments

Comments
 (0)