Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .license-header.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2025 Google LLC
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ repos:
rev: v2.4.1
hooks:
- id: codespell
args: ['--skip', '*.zip,*.log,*.json', '--ignore-words-list', 'crate,ans,ect,hist,nd']
args: ['--skip', '*.zip,*.log,*.json', '--ignore-words-list', 'crate,ans,ect,hist,nd,thw']
exclude: '^(\.git/|__pycache__|\.egg-info|dist/|build/|docs/_build/)'

# YAML validation specific to our timestamp configs
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ images:

# Option 2: Build from local wheel (uses local changes)
# To use: gcloud builds submit --config cloudbuild-wheel.yaml
# See cloudbuild-wheel.yaml for building with local wheel file
# See cloudbuild-wheel.yaml for building with local wheel file
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/logstory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions src/logstory/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -75,7 +75,7 @@

if api_type == "legacy" and not is_malachite_credential:
# This is a warning case - might still work but not typical
import warnings

Check failure on line 78 in src/logstory/auth.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLC0415)

src/logstory/auth.py:78:5: PLC0415 `import` should be at the top-level of a file

warnings.warn(
"Using non-malachite credentials with legacy API "
Expand Down Expand Up @@ -136,7 +136,7 @@
if self._credentials:
return self._credentials

# Priority: service_account_info > credentials_path > secret_manager
# Priority: service_account_info then credentials_path then secret_manager
if self.service_account_info:
self._credentials = service_account.Credentials.from_service_account_info(
self.service_account_info, scopes=self.SCOPES
Expand All @@ -149,7 +149,7 @@
)
elif self.secret_manager_credentials:
# Import here to avoid dependency if not using Secret Manager
from google.cloud import secretmanager

Check failure on line 152 in src/logstory/auth.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLC0415)

src/logstory/auth.py:152:7: PLC0415 `import` should be at the top-level of a file

client = secretmanager.SecretManagerServiceClient()
request = {"name": f"{self.secret_manager_credentials}/versions/latest"}
Expand Down Expand Up @@ -217,7 +217,7 @@
)
else:
# Try Application Default Credentials
import google.auth

Check failure on line 220 in src/logstory/auth.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLC0415)

src/logstory/auth.py:220:7: PLC0415 `import` should be at the top-level of a file

base_credentials, _ = google.auth.default(scopes=self.SCOPES)

Expand Down
4 changes: 2 additions & 2 deletions src/logstory/ingestion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -133,7 +133,7 @@
self,
log_type: str,
entries: list[dict[str, Any]],
labels: list[dict[str, str]],
labels: list[dict[str, str]], # noqa: ARG002
) -> None:
"""Post entities using legacy API."""
uri = f"{self.get_base_url()}/v2/entities:batchCreate"
Expand Down Expand Up @@ -236,7 +236,7 @@
list_url = f"{self.get_base_url()}/v1alpha/{parent}/forwarders"
response = self.http_client.get(list_url)

if response.status_code == 200:

Check failure on line 239 in src/logstory/ingestion.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLR2004)

src/logstory/ingestion.py:239:32: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
forwarders = response.json().get("forwarders", [])
for forwarder in forwarders:
if forwarder.get("displayName") == self.forwarder_name:
Expand All @@ -260,7 +260,7 @@
}

response = self.http_client.post(create_url, json=payload)
if response.status_code == 200:

Check failure on line 263 in src/logstory/ingestion.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLR2004)

src/logstory/ingestion.py:263:32: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
forwarder = response.json()
self._forwarder_id = forwarder["name"].split("/")[-1]
self._forwarder_cache[self.forwarder_name] = self._forwarder_id
Expand Down Expand Up @@ -394,7 +394,7 @@

def _check_response(self, response: real_requests.Response) -> None:
"""Check API response for errors."""
if response.status_code >= 400:

Check failure on line 397 in src/logstory/ingestion.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLR2004)

src/logstory/ingestion.py:397:32: PLR2004 Magic value used in comparison, consider replacing `400` with a constant variable
try:
response_data = response.json()
except ValueError:
Expand Down
2 changes: 1 addition & 1 deletion src/logstory/logstory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,7 @@
except Exception:
__version__ = "unknown"
typer.echo(f"logstory {__version__}")
raise typer.Exit()

Check failure on line 44 in src/logstory/logstory.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (RSE102)

src/logstory/logstory.py:44:21: RSE102 Unnecessary parentheses on raised exception help: Remove unnecessary parentheses


# Create Typer app and command groups
Expand Down Expand Up @@ -112,8 +112,8 @@
credentials_json = os.getenv("LOGSTORY_CREDENTIALS")
if credentials_json:
# Write to temp file and return path
import json

Check failure on line 115 in src/logstory/logstory.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLC0415)

src/logstory/logstory.py:115:5: PLC0415 `import` should be at the top-level of a file
import tempfile

Check failure on line 116 in src/logstory/logstory.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLC0415)

src/logstory/logstory.py:116:5: PLC0415 `import` should be at the top-level of a file

try:
# Validate it's valid JSON
Expand Down Expand Up @@ -315,7 +315,7 @@

# Handle --open flag as a special case
if open_usecase:
import subprocess # nosec B404

Check failure on line 318 in src/logstory/logstory.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (PLC0415)

src/logstory/logstory.py:318:5: PLC0415 `import` should be at the top-level of a file

usecase_dirs = glob.glob(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "usecases/*")
Expand Down
2 changes: 1 addition & 1 deletion src/logstory/logtypes_entities_timestamps.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/logstory/logtypes_events_timestamps.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/logstory/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
13 changes: 13 additions & 0 deletions src/logstory/usecases/NETWORK_ANALYSIS/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
13 changes: 13 additions & 0 deletions src/logstory/usecases/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2 changes: 1 addition & 1 deletion tests/analyze_all_timestamps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_change_map_implementation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_double_update_fix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_group_only_replacement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logstory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sysmon_pattern_edge_cases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_timestamp_patterns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_windows_sysmon_patterns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions tests/test_yaml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -101,9 +101,9 @@ def validate_base_time_format(filepath):
)

dateformat = timestamp["dateformat"]
if dateformat == 'epoch':
if dateformat == "epoch":
format_type = "epoch"
elif dateformat == 'windowsfiletime':
elif dateformat == "windowsfiletime":
format_type = "windowsfiletime"
else:
format_type = "dateformat"
Expand Down Expand Up @@ -191,7 +191,7 @@ def validate_epoch_dateformat_consistency(filepath):
)

# Validate dateformat values
valid_magic_formats = ['epoch', 'windowsfiletime']
valid_magic_formats = ["epoch", "windowsfiletime"]
if dateformat not in valid_magic_formats and not isinstance(dateformat, str):
raise ValueError(
f"Entry '{entry_name}' timestamp {i}: dateformat must be a string"
Expand Down
2 changes: 1 addition & 1 deletion tests/timestamp_extractor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion usecases/generate_usecase_docs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2025 Google LLC
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading