Skip to content

fix(logs): bind ARN tag operations to their owning group - #5810

Merged
pgermosen merged 3 commits into
floci-io:mainfrom
electrum:user/electrum/logs-direct-arn-tags-current
Oct 16, 2026
Merged

pgermosen merged 3 commits into
floci-io:mainfrom
electrum:user/electrum/logs-direct-arn-tags-current

Conversation

@electrum

@electrum electrum commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CloudWatch Logs ARN tag operations now authorize and access the same locally owned log group. Policies can grant or deny a group’s bare ARN and use its stored tags, requested tags and removal keys without a foreign ARN reading or changing a local group.

Literal plain names remain intact, including incomplete arn: prefixes; embedded markers cannot select a shortened local name. Canonical local ARN :* compatibility is retained. Tagging other Logs resource types remains unsupported.

Type of change

  • Bug fix (fix:)

AWS Compatibility

Covers TagResource, UntagResource and ListTagsForResource for log groups, including account, region and partition isolation, denied-mutation state and historical stored-name collisions. Preserves upstream rejection of colon-bearing credential regions.

Checked with 453 affected service/IAM/HTTP tests and AWS SDK for Java 2.55.11 on Java 17: 18 tests each in us-east-1 and cn-north-1. Package, Checkstyle, committed documentation and partition checks pass.

The IAM and Java SDK authorization tests share fixtures with the existing Logs stream tests, including the unknown-region and partition cases.

Checklist

  • Affected tests pass locally (scopes above)
  • New or updated integration test added
  • Commit messages follow Conventional Commits
  • Within two ready and four total open pull requests

Copilot AI balanced review requested due to automatic review settings October 16, 2026 13:40
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Bind CloudWatch Logs ARN tag operations to the owning log group

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Authorize log-group tag operations against the owning group’s bare ARN and tag conditions.
• Reject foreign ARNs and storage aliases before they can expose or change local tags.
• Cover grants, denies, ownership boundaries, and compatibility with integration and SDK tests.
Diagram

sequenceDiagram
    actor C as Caller
    participant F as IAM filter
    participant B as ARN builder
    participant T as Group target
    participant X as Condition resolver
    participant H as Logs handler
    participant S as Logs service
    C->>F: ARN tag request
    F->>B: Build policy resource
    B->>T: Resolve local group
    T-->>B: Bare group ARN
    F->>X: Gather tag conditions
    X->>S: Resolve target and read tags
    S->>T: Check ARN ownership
    F->>F: Evaluate policy
    F->>H: Forward authorized request
    H->>S: Access group tags
    S->>T: Check ARN ownership
    S-->>H: Result
    H-->>C: Response
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Pass a resolved target through request context
  • ➕ Parses the target once for authorization and execution.
  • ➖ Adds request-context plumbing between the IAM filter and Logs handler.
  • ➖ Requires a separate path for calls that bypass IAM enforcement.

Recommendation: Keep the shared target resolver used independently by IAM and the Logs service. It aligns their identity rules without coupling handler execution to IAM enforcement state.

Files changed (11) +587 / -13

Bug fix (5) +69 / -9
IamConditionContextResolver.javaSupply owning-group and request-tag IAM conditions +26/-5

Supply owning-group and request-tag IAM conditions

• Extends Logs condition resolution to direct ARN tag actions. Reads the resolved group’s stored tags and supplies requested tag values or removal keys where applicable.

src/main/java/io/github/hectorvent/floci/core/common/IamConditionContextResolver.java

CloudWatchLogsHandler.javaResolve ARN tag requests to locally owned groups +3/-3

Resolve ARN tag requests to locally owned groups

• Routes listing, adding, and removing tags through the shared target resolver before accessing a log group.

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsHandler.java

CloudWatchLogsService.javaValidate tag targets and stored group identity +6/-0

Validate tag targets and stored group identity

• Exposes local ARN target resolution and prevents shared tag mutators from changing a stored group whose name differs from the requested name.

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsService.java

LogGroupTagTarget.javaCentralize local log-group ARN resolution +28/-0

Centralize local log-group ARN resolution

• Introduces a shared name-and-ARN target for the three direct tag actions. Rejects foreign ARN owners and resource kinds while retaining plain-name and trailing ':*' compatibility.

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java

ResourceArnBuilder.javaAuthorize direct Logs tag actions against bare group ARNs +6/-1

Authorize direct Logs tag actions against bare group ARNs

• Builds the resolved log-group ARN for tag policy evaluation instead of using the wildcard resource. Other excluded Logs actions retain wildcard evaluation.

src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java

Tests (5) +500 / -1
CloudWatchLogsArnTagAuthorizationTest.javaExercise bare-ARN tag permissions through the AWS SDK +181/-0

Exercise bare-ARN tag permissions through the AWS SDK

• Adds SDK compatibility tests for exact grants and explicit denies across all three ARN tag actions. Checks that denied operations leave the other group’s tags unchanged.

compatibility-tests/sdk-test-java/src/test/java/com/floci/test/CloudWatchLogsArnTagAuthorizationTest.java

CloudWatchLogsServiceTest.javaCover historical stored-name collisions in tag mutations +30/-0

Cover historical stored-name collisions in tag mutations

• Verifies that alias lookups cannot add or remove tags from a differently named stored group, while access by its actual name still works.

src/test/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsServiceTest.java

LogsArnTagAuthorizationIntegrationTest.javaTest ARN tag authorization and ownership over HTTP +234/-0

Test ARN tag authorization and ownership over HTTP

• Covers exact grants and denies, account/region/partition isolation, stored-tag conditions, requested tag values, and removal keys. Confirms denied mutations preserve tags.

src/test/java/io/github/hectorvent/floci/services/iam/LogsArnTagAuthorizationIntegrationTest.java

LogsUnknownRegionAuthorizationIntegrationTest.javaTest direct tag actions in unknown and invalid regions +41/-0

Test direct tag actions in unknown and invalid regions

• Confirms an unambiguous unknown region works for all three ARN tag actions while a colon-bearing credential region retains its signature rejection.

src/test/java/io/github/hectorvent/floci/services/iam/LogsUnknownRegionAuthorizationIntegrationTest.java

ResourceArnBuilderTest.javaVerify bare Logs tag ARNs across partitions +14/-1

Verify bare Logs tag ARNs across partitions

• Checks all three actions produce bare group ARNs in standard, China, GovCloud, and custom regions, independently of the target header. Updates wildcard-action expectations.

src/test/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilderTest.java

Documentation (1) +18 / -3
iam.mdDocument Logs ARN tagging authorization +18/-3

Document Logs ARN tagging authorization

• Describes bare-ARN evaluation, local ownership checks, supported tag condition keys, and retained input compatibility. Clarifies that other Logs resource types remain unsupported.

docs/services/iam.md

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@qodo-code-review

qodo-code-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Disguised foreign ARNs still reach local groups ✓ Resolved
Description
LogGroupTagTarget.resolve rejects a foreign ARN only when the input starts with the exact
lowercase arn:. Any other input goes to extractLogGroupNameFromArn, which keeps whatever follows
the first :log-group: no matter what account, region or partition comes before it. So
ARN:aws:logs:eu-west-1:999999999999:log-group:prod,  arn:aws:logs:…:log-group:prod (leading
space) or x:log-group:prod is mapped to the local prod group, and TagResource, UntagResource and
ListTagsForResource then read or change that group's tags. That breaks the documented promise that a
different owner gets ResourceNotFoundException without touching local tags.
Code

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java[R16-21]

+        if (input.startsWith("arn:") && !input.startsWith(prefix)) {
+            throw new AwsException("ResourceNotFoundException", "The specified log group does not exist.", 400);
+        }
+        // Retain the handler's existing name/suffix coercion; do not add unrelated input restrictions.
+        String name = input.startsWith(prefix) ? input.substring(prefix.length())
+                : CloudWatchLogsHandler.extractLogGroupNameFromArn(input);
Relevance

●●● Strong

Recent precedents consistently accept rejecting foreign or malformed ARNs before local resource
lookup.

PR-#4504
PR-#5373
PR-#5576

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Only inputs that start with arn: are compared with the local prefix. All other inputs use the
legacy extractor, which cuts at :log-group: and throws away the owner segments. The handler and
ResourceArnBuilder both rely on this resolver, so a foreign owner written in a disguised form acts
on the local group. The docs promise the opposite.

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java[14-27]
src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsHandler.java[660-669]
docs/services/iam.md[1273-1281]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`LogGroupTagTarget.resolve` checks ownership only when the input starts with the exact lowercase `arn:`. Inputs such as `ARN:...:log-group:x`, ` arn:...:log-group:x` or `foo:log-group:x` skip the check, and `extractLogGroupNameFromArn` maps them to the local group `x`.

## Fix Focus Areas
- src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java[14-27]

## Recommended Fix
If the input does not start with the local prefix, treat it as a plain name only when it contains no `:log-group:` segment and does not start with `arn:` in any letter case. Otherwise throw `ResourceNotFoundException`. For example: `if (!input.startsWith(prefix) && (input.regionMatches(true, 0, "arn:", 0, 4) || input.contains(":log-group:"))) throw ...;`. Keep the plain-name `:*` coercion. Add tests for uppercase, leading-whitespace and non-`arn:` inputs that contain `:log-group:`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Some existing groups cannot be tagged ✓ Resolved
Description
LogGroupTagTarget.resolve rejects every input beginning with arn: unless it matches the local
log-group ARN prefix, including a plain group name such as arn:archive. Group creation accepts
that name, and the direct tag handlers previously passed it through unchanged, so tagging,
untagging, and listing its tags now fail with ResourceNotFoundException.
Code

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java[R16-17]

+        if (input.startsWith("arn:") && !input.startsWith(prefix)) {
+            throw new AwsException("ResourceNotFoundException", "The specified log group does not exist.", 400);
Relevance

●●● Strong

Preserving legacy plain-name behavior is consistent with accepted compatibility fixes and narrowly
scoped ARN validation.

PR-#4504
PR-#5694

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Creation checks only that the name is nonblank and stores it verbatim. The previous handler's name
extraction returns arn:archive unchanged because it has no :log-group: delimiter; the new guard
rejects it before any tag lookup.

src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsService.java[257-279]
src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsHandler.java[660-670]
src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java[14-21]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
A stored log group whose plain name begins with `arn:` is rejected by all three direct tag operations, despite the retained plain-name compatibility.
### Fix Focus Areas
- src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/LogGroupTagTarget.java[14-26]
- src/main/java/io/github/hectorvent/floci/services/cloudwatch/logs/CloudWatchLogsService.java[257-279]
### Recommended Fix
Recognize structurally complete ARNs before applying owner validation; preserve plain-name handling for values such as `arn:archive`. Add a regression test that creates such a group and exercises all three direct tag operations, while continuing to reject complete foreign ARNs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 8 rules
✅ Cross-repo context — repo relationships
  Explored: repo: floci-io/floci-ui (sha: ba041ac4) — View relationship
Review mode: Auto: 🧠 Deep: IAM authorization spans multiple paths with subtle ownership edge cases.

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@electrum

Copy link
Copy Markdown
Contributor Author

@pgermosen Both review findings are addressed: incomplete ARN prefixes stay literal, and noncanonical markers cannot select a shortened local group name. The new HTTP and SDK regressions pass, and the fresh CI checks pass. Ready for another look.

@pgermosen pgermosen added bug Something isn't working cloudwatch Amazon CloudWatch (Logs & Metrics) labels Oct 16, 2026

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@electrum thanks, the ARN binding and the condition keys look right to me, and both Qodo points are settled. Not approving yet, though, because the tests copy existing harnesses.

CloudWatchLogsArnTagAuthorizationTest repeats the setUp, cleanup, policy, assertDenied and client of CloudWatchLogsStreamAuthorizationTest almost line for line. LogsArnTagAuthorizationIntegrationTest copies call and user from LogsStreamAuthorizationIntegrationTest, and the new test in LogsUnknownRegionAuthorizationIntegrationTest inlines another user plus PutUserPolicy block and the same tag body and expected tags as invoke and expectedTags.

Could you pull these into shared fixtures, the IAM side next to EnforcementFixtures, and move the existing Logs copies onto them?

@pgermosen pgermosen added the waiting-author Review posted; waiting on the PR author to respond label Oct 16, 2026

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@electrum thanks, that's the shape I was after: LogsAuthorizationFixtures builds its users on EnforcementFixtures, both SDK tests extend one CloudWatchLogsAuthorizationFixture, and the existing stream and unknown-region tests now use them too. This looks good to me.

@pgermosen pgermosen removed the waiting-author Review posted; waiting on the PR author to respond label Oct 16, 2026
@pgermosen
pgermosen merged commit 49a3ff9 into floci-io:main Oct 16, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cloudwatch Amazon CloudWatch (Logs & Metrics)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants