Skip to content

akamai migration#2888

Open
mchupeau-sk wants to merge 1 commit into
developfrom
imp/akmai-migration
Open

akamai migration#2888
mchupeau-sk wants to merge 1 commit into
developfrom
imp/akmai-migration

Conversation

@mchupeau-sk

@mchupeau-sk mchupeau-sk commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary by Sourcery

Migrate the Akamai automation module from Poetry to uv and update it for Python 3.14, including related tooling, configuration, and minor code/test adjustments.

Enhancements:

  • Modernize Akamai module code for Python 3.14 and current libraries, including pydantic v2 usage and typing tweaks.

Build:

  • Switch Akamai module packaging from Poetry to PEP 621 / uv with updated runtime and dev dependencies.
  • Update Dockerfile to use Python 3.14, install dependencies via uv, and configure a writable TMPDIR for the runtime user.

Documentation:

  • Record the uv migration and version bump in the Akamai module changelog.

Tests:

  • Adjust Akamai WAF tests for updated datetime and configuration typing behavior.

Chores:

  • Update Akamai module manifest version to 1.1.0 and add a module-specific mise configuration.

@mchupeau-sk mchupeau-sk self-assigned this Jul 10, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Migrates the Akamai module from Poetry to uv and Python 3.14, updates tooling (ruff, mypy, pytest), adjusts Docker image and runtime environment accordingly, modernizes typing/timezone usage, and aligns configuration/manifest versions.

File-Level Changes

Change Details Files
Migrate Akamai module build configuration from Poetry to PEP 621/uv and update dependencies/tooling for Python 3.14.
  • Replace [tool.poetry] configuration with a PEP 621 [project] table including runtime dependencies and Python requirement >=3.14,<4.
  • Introduce uv-specific configuration ([tool.uv]) and dependency groups for dev and lint dependencies.
  • Configure ruff, mypy, and pytest via pyproject.toml, including test paths, coverage options, and per-file ignores.
  • Remove legacy black/isort/poetry sections and old dev dependency declarations.
Akamai/pyproject.toml
Update container build pipeline to use uv with Python 3.14 and ensure runtime temp directory is writable for non-root user.
  • Switch base image from python:3.11 to python:3.14.
  • Install uv via multi-stage COPY and use uv sync with uv.lock to install dependencies into a local virtualenv.
  • Export the project venv on PATH and add a dedicated writable /app/tmp directory with TMPDIR set for the runtime user.
  • Remove Poetry installation and usage from the Dockerfile.
Akamai/Dockerfile
Align Akamai WAF connector typing and timezone handling with modern Python and pydantic v2.
  • Switch pydantic imports from pydantic.v1 to pydantic and adjust Field usage to pydantic v2-compatible patterns.
  • Use datetime.UTC instead of timezone.utc and refine Generator type hints to modern collections.abc.Generator with simplified return types.
  • Update imports accordingly (remove unused timezone, typing.Generator).
Akamai/akamai_modules/connector_akamai_waf.py
Update configuration models to pydantic v2-style secret metadata.
  • Replace Field(..., secret=True) with json_schema_extra={'secret': True} for secret fields in AkamaiModuleConfiguration.
  • Update pydantic import path to pydantic instead of pydantic.v1.
Akamai/akamai_modules/models.py
Adjust tests and manifest to match new timezone and configuration expectations and bump module version.
  • Use datetime.UTC instead of timezone.utc in tests for consistency with production code.
  • Update test fixture configuration to pass config_id as a string to match connector expectations.
  • Bump manifest version from 1.0.1 to 1.1.0 and document the migration in the changelog.
  • Add module-specific mise configuration for Python 3.14 and a shared .venv, and replace poetry.lock with uv.lock.
Akamai/tests/test_akamai_waf.py
Akamai/manifest.json
Akamai/CHANGELOG.md
Akamai/mise.toml
Akamai/uv.lock
Akamai/poetry.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​botocore@​1.43.449110010010070
Addedpypi/​mypy@​2.2.076100100100100
Updatedpypi/​edgegrid-python@​2.0.0 ⏵ 2.0.799100100100100
Addedpypi/​boto3@​1.43.4499100100100100

View full report

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Fixed security issues:

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="Akamai/akamai_modules/connector_akamai_waf.py" line_range="140-143" />
<code_context>
             event["httpMessage"]["responseHeaders"] = response_headers

-    def __fetch_next_events(self, from_date: int) -> Generator[list, None, None]:
+    def __fetch_next_events(self, from_date: int) -> Generator[list]:
         url = f"{self.module.configuration.base_url}/siem/v1/configs/{self.configuration.config_id}"
         response = self.client.get(
</code_context>
<issue_to_address>
**suggestion:** Clarify the generator element types for better static checking and readability.

Since you’re updating the hints, please specify the yielded types more precisely. For example, `__fetch_next_events` could be `Generator[list[dict[str, Any]], None, None]`, and `fetch_events` / `filter_processed_events` `Generator[dict[str, Any], None, None]`. This helps mypy and readers understand the data shape flowing through the connector.

Suggested implementation:

```python
from cachetools import Cache, LRUCache
from pydantic import Field
from typing import Any, Generator
from sekoia_automation.checkpoint import CheckpointTimestamp, TimeUnit
from sekoia_automation.connector import Connector, DefaultConnectorConfiguration

```

```python
        if "responseHeaders" in event.get("httpMessage", {}):
            event["httpMessage"]["responseHeaders"] = response_headers

    def __fetch_next_events(self, from_date: int) -> Generator[list[dict[str, Any]], None, None]:

```

```python
            )

    def fetch_events(self) -> Generator[dict[str, Any], None, None]:
        most_recent_date_seen: int = self.from_timestamp

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +140 to 143
def __fetch_next_events(self, from_date: int) -> Generator[list]:
url = f"{self.module.configuration.base_url}/siem/v1/configs/{self.configuration.config_id}"
response = self.client.get(
url=url, params={"from": from_date, "limit": self.page_size}, timeout=60, stream=True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Clarify the generator element types for better static checking and readability.

Since you’re updating the hints, please specify the yielded types more precisely. For example, __fetch_next_events could be Generator[list[dict[str, Any]], None, None], and fetch_events / filter_processed_events Generator[dict[str, Any], None, None]. This helps mypy and readers understand the data shape flowing through the connector.

Suggested implementation:

from cachetools import Cache, LRUCache
from pydantic import Field
from typing import Any, Generator
from sekoia_automation.checkpoint import CheckpointTimestamp, TimeUnit
from sekoia_automation.connector import Connector, DefaultConnectorConfiguration
        if "responseHeaders" in event.get("httpMessage", {}):
            event["httpMessage"]["responseHeaders"] = response_headers

    def __fetch_next_events(self, from_date: int) -> Generator[list[dict[str, Any]], None, None]:
            )

    def fetch_events(self) -> Generator[dict[str, Any], None, None]:
        most_recent_date_seen: int = self.from_timestamp

@squioc squioc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the work.

It seems that some tasks are missing from the mise.toml file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this file?

Comment thread Akamai/mise.toml
python = "3.14"

[env]
_.python.venv = { path = ".venv", create = false }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_.python.venv = { path = ".venv", create = false }
_.python.venv = { path = ".venv", create = false }
[tasks.test]
description = "Run tests"
run = "uv run pytest tests/"
[tasks.lint]
description = "Check code style and types"
run = [
"uv run ruff check .",
"uv run ruff format --check .",
"uv run mypy .",
]
[tasks.format]
description = "Format and auto-fix code"
run = [
"uv run ruff check --fix .",
"uv run ruff format .",
]
[tasks.check]
description = "Check typing"
run = "uvx mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --hide-error-context ."
[tasks.compliance]
description = "check the compliance of the automation module"
dir = "../utils"
run = "uv run python compliance check --changes"
[tasks.validate]
description = "Check the automation module"
depends = ["lint", "format", "check", "compliance"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants