Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kazet committed Mar 5, 2024
2 parents 294e569 + 991b69f commit bbdeedf
Show file tree
Hide file tree
Showing 25 changed files with 505 additions and 255 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ repos:
- prometheus-client==0.17.1
- pymongo-stubs==0.2.0
- requests_mock==1.11.0
- sqlalchemy-stubs==0.4
- typer==0.9.0
- types-beautifulsoup4==4.12.0.6
- types-Markdown==3.4.2.10
Expand Down
15 changes: 8 additions & 7 deletions artemis/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_analyses_table(
start: int = Query(),
length: int = Query(),
) -> Dict[str, Any]:
ordering = _get_ordering(request, column_names=["payload.data", "payload_persistent.tag", None, None])
ordering = _get_ordering(request, column_names=["target", "tag", None, None])
search_query = _get_search_query(request)

karton_state = KartonState(backend=KartonBackend(config=KartonConfig()))
Expand All @@ -62,16 +62,17 @@ def get_analyses_table(

entries = []
for entry in result.data:
if entry["_id"] in karton_state.analyses:
num_active_tasks = len(karton_state.analyses[entry["_id"]].pending_tasks)
if entry["id"] in karton_state.analyses:
num_active_tasks = len(karton_state.analyses[entry["id"]].pending_tasks)
else:
num_active_tasks = 0

entries.append(
{
"payload": entry["payload"],
"payload_persistent": entry["payload_persistent"],
"id": entry["_id"],
"id": entry["id"],
"tag": entry["tag"],
"payload": entry["task"]["payload"],
"payload_persistent": entry["task"]["payload_persistent"],
"num_active_tasks": num_active_tasks,
"stopped": entry.get("stopped", None),
}
Expand All @@ -96,7 +97,7 @@ def get_task_results_table(
) -> Dict[str, Any]:
ordering = _get_ordering(
request,
column_names=["created_at", "tag", "headers.receiver", "target_string", None, "status_reason"],
column_names=["created_at", "tag", "receiver", "target_string", None, "status_reason"],
)
search_query = _get_search_query(request)

Expand Down
13 changes: 10 additions & 3 deletions artemis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ def get_config(name: str, **kwargs) -> Any: # type: ignore

class Config:
class Data:
DB_CONN_STR: Annotated[str, "Connection string to the MongoDB database."] = get_config("DB_CONN_STR")

POSTGRES_CONN_STR: Annotated[str, "Connection string to the PostgreSQL database."] = get_config(
"POSTGRES_CONN_STR"
)
REDIS_CONN_STR: Annotated[str, "Connection string to Redis."] = get_config("REDIS_CONN_STR")

LEGACY_MONGODB_CONN_STR: Annotated[
str,
"Connection string to the MongoDB database. MongoDB is not used anymore - it is present here to seamlessly "
"migrate data from older Artemis versions to PostgreSQL.",
] = get_config("DB_CONN_STR")

class Reporting:
REPORTING_MAX_VULN_AGE_DAYS: Annotated[
int, "When creating e-mail reports, what is the vulnerability maximum age (in days) for it to be reported."
] = get_config("REPORTING_MAX_VULN_AGE_DAYS", default=50, cast=int)
] = get_config("REPORTING_MAX_VULN_AGE_DAYS", default=60, cast=int)

REPORTING_SEPARATE_INSTITUTIONS: Annotated[
List[str],
Expand Down
Loading

0 comments on commit bbdeedf

Please sign in to comment.