Skip to content

Implement constrained extensions in RCv2#74

Merged
alsanmsft merged 18 commits into
mainfrom
dev/anasanc/pep-onboardrcv2
Jun 26, 2026
Merged

Implement constrained extensions in RCv2#74
alsanmsft merged 18 commits into
mainfrom
dev/anasanc/pep-onboardrcv2

Conversation

@alsanmsft

Copy link
Copy Markdown
Collaborator

As per this spec , for Constrained extensions, customers can specify what kinds of script are and are not allowed to run. Customers may want to limit their run command to only run gallery scripts, only inline scripts or only run certain allow listed scripts.

This PR implements that logic using allowlists of hashes. The RCv2 behavior changes are as follows:

When there's a policy present, RCv2 can

  • Limit scripts it runs based on script type

  • Limit command IDs it runs based on an allowlist

  • Limit downloaded scripts it runs based on a hash allowlist (RCv2 validates the scripts after downloading it)

  • Validate that the user in the RunAsUser settings property is permitted by policy.

The code changes required to support this behavior are:

  • The code references the shared common library extensionpolicysettings in azure-extension-platform
  • Updates to HandlerSettings to reflect that the CommandId and ScriptType properties are being sent down from CRP
  • There is a new extensionpolicysettingsRC folder, with types relating to extensionpolicysettings (including a policy struct, a flag type, etc) in types.go and Handler Settings validation against the policy in extensionpolicysettingsRC.go
  • Unit tests for the above changes

The changes in this PR do not affect RC's existing behavior from a customer perspective, but accurately fetch information from CRP and initialize extension policy as desired. The behavior change that depends on different policy configurations is covered in UTs.

Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated

@D1v38om83r D1v38om83r 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.

Approved with suggestions.

Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go

@D1v38om83r D1v38om83r 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.

Approved with comment.

Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc_test.go Outdated
Comment thread internal/cmds/cmds_test.go
Comment thread internal/cmds/cmds.go Outdated
Comment thread internal/constants/exitcodes.go
Comment thread internal/constants/exitcodes.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/cmds/cmds.go Outdated
Comment thread internal/cmds/cmds.go Outdated
Comment thread internal/extensionpolicysettingsrc/extensionpolicysettingsrc.go Outdated
Comment thread internal/cmds/cmds.go
Comment thread internal/cmds/cmds.go Outdated
Comment thread internal/cmds/cmds.go
@alsanmsft alsanmsft merged commit 8cfc618 into main Jun 26, 2026
5 checks passed
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.

5 participants