Skip to content

Emit ASSUMABLE_ROLE NHI type for IAM roles (NHI Phase-1 K3)#126

Open
c1-squire-dev[bot] wants to merge 3 commits into
mainfrom
nhi/emit-nhi-role
Open

Emit ASSUMABLE_ROLE NHI type for IAM roles (NHI Phase-1 K3)#126
c1-squire-dev[bot] wants to merge 3 commits into
mainfrom
nhi/emit-nhi-role

Conversation

@c1-squire-dev

@c1-squire-dev c1-squire-dev Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Implements NHI Phase-1 K3 type emission (per the NHI RFC §6 row 1); IAM roles (TRAIT_ROLE) → WithNHIType(NHI_TYPE_ASSUMABLE_ROLE, detail).

Per §6 this is a mod: the trust-policy classification is parsed at sync time inside roleResourceType.List() (pkg/connector/role.go), so the NHI type + detail land on every synced role with no extra API call (ListRoles already returns AssumeRolePolicyDocument + Path inline).

Detail strings follow the §2.8 convention <platform>.<object>[.<purpose>] (dotted lowercase), most-specific first:

  • service-linked role (path /aws-service-role/) → aws.role.service_linked
  • trusted by an AWS service principal → aws.role.<service> (e.g. aws.role.lambda, aws.role.ec2, aws.role.ecs_tasks)
  • trusted by a federated provider → aws.role.oidc / aws.role.saml / aws.role.federated
  • trusted by an AWS principal in a different account → aws.role.cross_account
  • otherwise → aws.role

The existing AWS-principal assume-role grant path is unchanged; Service/Federated trust principals (previously discarded in Principal.UnmarshalJSON) are now retained solely for classification.

Self-bumps baton-sdk → v0.11.0 (interim; rebases after the baton-admin fleet bump). No protogen. Verified the shipped v0.11.0 API is WithNHIType / NonHumanIdentityTrait_NHI_TYPE_ASSUMABLE_ROLE (the RFC's WithNHISubtype was a stale draft name).

go build ./..., go test ./..., and golangci-lint run all pass; added TestClassifyRoleNHIDetail covering each branch.


🛰️ Built with pqprime.

@c1-squire-dev c1-squire-dev Bot requested a review from a team May 31, 2026 15:54
@github-actions

github-actions Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Connector PR Review: Emit ASSUMABLE_ROLE NHI type for IAM roles (NHI Phase-1 K3)

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Review mode: full
View review run

Review Summary

This PR adds NHI (Non-Human Identity) type classification for IAM roles at sync time using the trust policy already returned by ListRoles. Service-linked roles are classified as MANAGED_IDENTITY, all others as ASSUMABLE_ROLE with detail strings based on trust principals (service, federated, cross-account). The Principal.UnmarshalJSON is refactored to also parse Service and Federated fields (previously silently ignored), which are used only for NHI classification — the existing AWS-principal grant path is unchanged. The new extractTrustPrincipalsByKind correctly uses strings.HasPrefix to match all sts:AssumeRole* variants (including WithWebIdentity and WithSAML), while the existing extractTrustPrincipals retains its exact-match semantics for grants. CI is updated to install the baton CLI from the baton-sdk releases. Test coverage is thorough across all classification branches. No issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions github-actions 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.

No blocking issues found.

@c1-squire-dev c1-squire-dev Bot force-pushed the nhi/emit-nhi-role branch from ba8b3e5 to 5dc7ee3 Compare May 31, 2026 16:49

@github-actions github-actions 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.

No blocking issues found.

@github-actions github-actions 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.

No blocking issues found.

@github-actions github-actions 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.

No blocking issues found.

pquerna and others added 3 commits June 1, 2026 04:11
Implements NHI Phase-1 K3 type emission (per the NHI RFC §6 row 1); IAM
roles (TRAIT_ROLE) are annotated WithNHIType(NHI_TYPE_ASSUMABLE_ROLE,
detail). The trust-policy classification is parsed at sync time in
List() so the type detail is set on every synced role.

Detail strings follow the §2.8 convention <platform>.<object>[.<purpose>]:
service-linked roles -> aws.role.service_linked; service-trusted ->
aws.role.<service> (e.g. aws.role.lambda); federated -> aws.role.oidc/
saml/federated; cross-account -> aws.role.cross_account; else aws.role.

Self-bumps baton-sdk -> v0.11.0 (interim; rebases after the baton-admin
fleet bump). The existing AWS-principal grant path is unchanged; Service
and Federated trust principals are now retained solely for classification.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
…archived (v0.4.5) and can't resolve NonHumanIdentityTrait

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
…366)

AWS service-linked roles are platform-custodied — the org doesn't control
their trust policy, AWS does — so they map to NHI_TYPE_MANAGED_IDENTITY
rather than ASSUMABLE_ROLE. Detected by the reserved /aws-service-role/
path or the AWSServiceRoleFor* name prefix; all other roles keep
ASSUMABLE_ROLE with their existing trust-derived detail.

Bumps baton-sdk to v0.11.1, which adds NHI_TYPE_MANAGED_IDENTITY=3.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@c1-squire-dev c1-squire-dev Bot force-pushed the nhi/emit-nhi-role branch from f5d6965 to 8c8aab3 Compare June 1, 2026 04:13

@github-actions github-actions 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.

No blocking issues found.

@johnallers johnallers self-assigned this Jun 23, 2026
Comment thread .github/workflows/ci.yaml
Comment on lines +23 to +34
- name: Install baton CLI from baton-sdk (conductorone/baton is archived)
run: |
set -euxo pipefail
BATON_VERSION=v0.11.0
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
if [ "${ARCH}" = "x86_64" ]; then ARCH="amd64"; fi
FILENAME="baton-${BATON_VERSION}-${OS}-${ARCH}.tar.gz"
curl -fsSL -O "https://github.com/conductorone/baton-sdk/releases/download/${BATON_VERSION}/${FILENAME}"
tar xzf "${FILENAME}"
mv baton /usr/local/bin/baton
baton --version

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.

This is probably unnecessary. I think this was addressed by ConductorOne/github-workflows#89

@linear-code

linear-code Bot commented Jun 23, 2026

Copy link
Copy Markdown

CXP-605

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.

2 participants