Skip to content

Fix secret injection argument placement for plain and static functions - #83

Open
Muneer320 wants to merge 1 commit into
aws:masterfrom
Muneer320:fix/decorator-argument-classification
Open

Muneer320 wants to merge 1 commit into
aws:masterfrom
Muneer320:fix/decorator-argument-classification

Conversation

@Muneer320

@Muneer320 Muneer320 commented Nov 9, 2026 •

Copy link
Copy Markdown

Description

Why is this change being made?

InjectSecretString mistakes get(secret, request) for an instance method when request is a dictionary, because dict.get exists. It injects the secret after the request instead of before it. A static method receiving an instance of its containing class has the same problem.

What is changing?

Check whether the first argument's class hierarchy actually contains a method wrapping the decorated function, instead of checking for an unrelated attribute with the same name. Exclude static/class-method descriptors from instance-method classification, while preserving inherited methods, super() calls, outer lru_cache wrappers, and properties. Secret retrieval remains per invocation except when an existing outer decorator itself caches the call.

Related Links


Testing

How was this tested?

GitHub-hosted Ubuntu 22.04, Python 3.9.25 and 3.13.18, exact base b66d1a9866dc7d96fb246039def477038ce0f5da:

  1. Before the source fix, the plain-function and static-method regressions fail; four instance-method compatibility controls pass.
  2. Afterward, all 52 unit tests pass on both Python versions, with 99.31% coverage against the required 90% threshold.
  3. The upstream fatal-error flake8 check, pylint (10.00/10), Ruff 0.15.22, and git diff --check pass.

An initial Python 3.9 attempt stopped at interpreter setup on Ubuntu 26.04. The final jobs use Ubuntu 22.04 and both pass. No live AWS integration tests were run; the suite uses stubbed service responses and the new cases use a mock cache.

When testing locally, provide testing artifact(s):

Tests ran on hosted runners, not on the local laptop:


Reviewee Checklist

Update the checklist after submitting the PR

  • I have reviewed, tested and understand all changes
  • I have filled out the Description and Testing sections above
  • Build and Unit tests are passing
    Editable-package installation and all 52 unit tests pass in both hosted jobs.
  • Unit test coverage check is passing
  • Integration tests pass locally
  • I have updated integration tests (if needed)
    Not needed for decorator argument placement; unit regressions cover the changed behavior.
  • I have ensured no sensitive information is leaking (i.e., no logging of sensitive fields, or otherwise)
    No logging was added; regression secrets are fixed test strings.
  • I have added explanatory comments for complex logic, new classes/methods and new tests
    Classification has an explanatory comment and regression names identify the compatibility cases.
  • I have updated README/documentation (if needed)
    No public API or documented usage change; the fix restores the existing injection contract.
  • I have clearly called out breaking changes (if any)
    No intentional breaking API change.

Reviewer Checklist

All reviewers please ensure the following are true before reviewing:

  • Reviewee checklist has been accurately filled out
  • Code changes align with stated purpose in description
  • Test coverage adequately validates the changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Muneer320
Muneer320 requested a review from a team as a code owner November 9, 2026 16:24
@Muneer320

Copy link
Copy Markdown
Author

The linked hosted jobs pass all 52 unit tests with 99.31% coverage on Python 3.9 and 3.13, plus pylint, Ruff and the upstream fatal-error flake8 check. Could a maintainer approve the pending Python package workflow? The description records the initial Python 3.9 runner-image limitation and the successful Ubuntu 22.04 checks.

This branch has not been deployed

No deployments
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.

InjectSecretString misclassifies plain functions with dictionary arguments

1 participant