Skip to content

Commit 041d6fd

Browse files
author
Lee Chagolla-Christensen
committed
more linting, minor enrichment skill update
1 parent 2a028ad commit 041d6fd

16 files changed

Lines changed: 46 additions & 39 deletions

File tree

.claude/skills/enrichment-module-builder.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ class Test{ModuleName}Analyzer:
423423
# Assert on results
424424
```
425425

426+
Guidelines:
427+
- Test both positive(happy path) and negative(unhappy path) cases.
428+
- Do this for all result types, findings, transforms, DB writes, and file uploads generated.
429+
- Handle edge cases and error conditions
430+
431+
426432
### Run Tests
427433

428434
```bash

libs/chromium/chromium/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def is_valid_text(data: bytes) -> bool:
295295

296296

297297
def byte_xor(ba1, ba2):
298-
return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)])
298+
return bytes([_a ^ _b for _a, _b in zip(ba1, ba2, strict=False)])
299299

300300

301301
def parse_abe_blob(abe_data: bytes, chromekey: bytes | None = None) -> dict | None:

libs/common/common/models2/dpapi.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""DPAPI credential models for API requests."""
22

33
import re
4-
from typing import Annotated, Literal, Union
4+
from typing import Annotated, Literal
55
from uuid import UUID
66

77
from common.logger import get_logger
@@ -201,15 +201,13 @@ def get_credential_type(v):
201201

202202

203203
type DpapiCredentialRequest = Annotated[
204-
Union[
205-
Annotated[PasswordCredentialKey, Tag("password")],
206-
Annotated[NtlmHashCredentialKey, Tag("cred_key_ntlm")],
207-
Annotated[Sha1CredentialKey, Tag("cred_key_sha1")],
208-
Annotated[Pbkdf2StrongCredentialKey, Tag("cred_key_pbkdf2")],
209-
Annotated[DomainBackupKeyCredential, Tag("domain_backup_key")],
210-
Annotated[MasterKeyGuidPairList, Tag("master_key_guid_pair")],
211-
Annotated[DpapiSystemCredentialRequest, Tag("dpapi_system")],
212-
Annotated[ChromiumAppBoundKeyCredential, Tag("chromium_app_bound_key")],
213-
],
204+
Annotated[PasswordCredentialKey, Tag("password")]
205+
| Annotated[NtlmHashCredentialKey, Tag("cred_key_ntlm")]
206+
| Annotated[Sha1CredentialKey, Tag("cred_key_sha1")]
207+
| Annotated[Pbkdf2StrongCredentialKey, Tag("cred_key_pbkdf2")]
208+
| Annotated[DomainBackupKeyCredential, Tag("domain_backup_key")]
209+
| Annotated[MasterKeyGuidPairList, Tag("master_key_guid_pair")]
210+
| Annotated[DpapiSystemCredentialRequest, Tag("dpapi_system")]
211+
| Annotated[ChromiumAppBoundKeyCredential, Tag("chromium_app_bound_key")],
214212
Field(discriminator=Discriminator(get_credential_type)),
215213
]

libs/common/common/state_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_file_enriched(object_id: str) -> FileEnriched:
111111
raise RuntimeError("Query returned no column descriptions")
112112

113113
columns = [desc[0] for desc in cur.description]
114-
file_data = dict(zip(columns, result))
114+
file_data = dict(zip(columns, result, strict=True))
115115

116116
# Transform data using shared helper
117117
file_data = _transform_file_enriched_data(file_data)

libs/common/common/workflows/workflow_purger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ async def _run_purge_cycle(self) -> dict:
318318
# Collect successfully purged workflow IDs
319319
purged_wf_ids = []
320320

321-
for wf_id, result in zip(workflow_ids, purge_results):
321+
for wf_id, result in zip(workflow_ids, purge_results, strict=True):
322322
if isinstance(result, Exception):
323323
logger.error(
324324
"Purge operation failed with exception",

libs/file_enrichment_modules/file_enrichment_modules/dotnet/analyzer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import hashlib
33
import json
44
from pathlib import Path
5-
from typing import Union
65

76
import dnfile
87
from common.logger import get_logger
@@ -57,7 +56,7 @@ def process_resources(assembly):
5756
return resources
5857

5958

60-
def parse_dotnet_assembly(filename: Union[str, Path]) -> dict:
59+
def parse_dotnet_assembly(filename: str | Path) -> dict:
6160
"""
6261
Parses a .NET assembly file and returns a dictionary of .NET specific data.
6362
"""

libs/file_enrichment_modules/file_enrichment_modules/sqlite/analyzer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def format_sqlite_data(database_data: dict) -> str:
7272
continue
7373

7474
# Show schema with column types
75-
schema_with_types = [f"{col} ({type_})" for col, type_ in zip(data["schema"], data["column_types"])]
75+
schema_with_types = [
76+
f"{col} ({type_})" for col, type_ in zip(data["schema"], data["column_types"], strict=True)
77+
]
7678
output.append(f"Schema: {', '.join(schema_with_types)}")
7779

7880
output.append("Data:")

projects/agents/agents/schemas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import StrEnum
2-
from typing import Any, Literal, Union
2+
from typing import Any, Literal
33

44
from pydantic import BaseModel, Field, field_validator
55

@@ -27,7 +27,7 @@ class TriageRequest(BaseModel):
2727
finding_id: int = Field(..., description="Unique finding identifier")
2828
finding_name: str = Field(..., description="Name/type of the finding")
2929
category: str | None = Field(None, description="Finding category")
30-
severity: Union[int, str] | None = Field(None, description="Finding severity level (0-10 or string)")
30+
severity: int | str | None = Field(None, description="Finding severity level (0-10 or string)")
3131
object_id: str = Field(..., description="Object storage ID")
3232
origin_type: str | None = Field(None, description="Type of the finding's origin")
3333
origin_name: str | None = Field(None, description="Name of the finding's origin")

projects/cli/cli/cobaltstrike_connector/download_processor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from dataclasses import dataclass
66
from datetime import UTC, datetime
77
from pathlib import Path
8-
from typing import Union
98

109
import plyvel
1110
from cli.cobaltstrike_connector.cobaltstrike_client import Beacon, CobaltStrikeClient, Download
@@ -92,7 +91,7 @@ def mark_processed(
9291

9392
async def upload_file(
9493
self,
95-
file_path: Union[Path, str],
94+
file_path: Path | str,
9695
metadata: FileMetadata,
9796
delete_after: bool = False,
9897
) -> tuple[bool, str | None, FileWithMetadataResponse | None]:

projects/cli/cli/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Annotated, Union
2+
from typing import Annotated
33
from urllib.parse import urlparse
44

55
import yaml
@@ -63,7 +63,7 @@ class NemesisConfig(BaseConfig):
6363

6464
class MythicConfig(BaseConfig):
6565
url: StrictHttpUrl
66-
credential: Union[PasswordCredential, TokenCredential]
66+
credential: PasswordCredential | TokenCredential
6767

6868
@field_validator("credential")
6969
@classmethod

0 commit comments

Comments
 (0)