Getting started with Continuum for software supply chain
AWS Continuum for software supply chain is in preview release and is subject to change.
In this tutorial, you protect an npm install with AWS Continuum for software supply chain. You run the same install three
times and watch the decision change: first with no policy, then with a policy rule in audit mode,
then with the rule in enforce mode. You install packages with the Continuum for software supply chain CLI, and you
manage the policy and review decisions with the AWS Command Line Interface (AWS CLI). The example package is
lodash version 4.17.21. In each AWS CLI command, replace region with an AWS Region where Continuum for software supply chain is available, such as us-east-1.
For the terms used in this tutorial, such as policies, rules, enforcement modes, and package decisions, see AWS Continuum for software supply chain concepts.
Prerequisites
Before you start, make sure that you have the following:
-
An AWS account.
-
IAM permissions for the actions that this tutorial uses. The Continuum for software supply chain CLI needs
continuum:CreatePackageDecision. The policy and decision steps needcontinuum:CreateSupplyChainPolicy,continuum:UpdateSupplyChainPolicy,continuum:DeleteSupplyChainPolicy,continuum:ListPackageDecisions, andcontinuum:GetPackageDecision. For more information, see Identity and access management for AWS Continuum. -
The AWS CLI, installed and configured with credentials for the account and an AWS Region where Continuum for software supply chain is available. For the Regions, see Regions and endpoints.
-
npm, on the machine where you run the install. For the other package managers that the Continuum for software supply chain CLI supports, see Run a package manager through the CLI.
Step 1: Install the Continuum for software supply chain CLI
The Continuum for software supply chain CLI runs a package manager for you and requests a package decision for
each package as the package manager downloads it. You put the cscf command before a
package manager command, as in cscf npm install .
For what the CLI checks, see Protecting package installs with the Continuum for software supply chain CLI.package
Install the CLI from npm or from PyPI. Use one of the following commands.
To install from npm:
PROMPT>npm install --global @aws-continuum/continuum-supply-chain-firewall
To install from PyPI:
PROMPT>pip install aws-continuum-supply-chain-firewall
To check the install, print the CLI's version:
PROMPT>cscf --version
The CLI uses the same AWS credentials as the AWS CLI. For more information, see Credentials.
Step 2: Install a package that no rule matches
Run the install through the Continuum for software supply chain CLI:
PROMPT>cscf npm install lodash@4.17.21
No rule matches the package yet, and the package isn't malicious, so Continuum for software supply chain allows
it. The package manager installs the package, and the CLI returns with exit code 0. For
every exit code, see Exit codes and fail-open behavior.
Step 3: Create a policy in audit mode
Create a policy with one rule that matches lodash version 4.17.21. Start the
rule in audit mode, so Continuum for software supply chain records what it would deny without blocking anything.
-
Save the following policy as
audit-policy.json:{ "name": "block-lodash", "description": "Block lodash 4.17.21 while we evaluate it", "rules": [ { "ruleId": "deny-lodash", "enforcementMode": "AUDIT", "denyWhen": { "allOf": [ { "signal": "PACKAGE_IDENTITY", "operator": "MATCHES", "value": { "packageIdentity": { "ecosystem": "npm", "name": "lodash", "version": "4.17.21" } } } ] } } ] } -
Create the policy, and note the policy ID in the output for the next steps:
PROMPT>aws continuum create-supply-chain-policy \ --regionregion\ --policy file://audit-policy.json { "id": "policy-id", "arn": "policy-arn", "policy": { "name": "block-lodash", ... }, "createdAt": "timestamp", "updatedAt": "timestamp" }NoteIf you receive errors when you run AWS CLI commands, see Troubleshooting errors for the AWS CLI in the AWS CLI User Guide. Also, make sure that you're using the most recent AWS CLI version.
-
Remove the package and clear npm's cache, so that the next install downloads the package again. The Continuum for software supply chain CLI checks only the packages that the package manager downloads:
PROMPT>npm uninstall lodashPROMPT>npm cache clean --force -
Run the install again. The rule matches the package, but it runs in audit mode, so the install still runs and the CLI returns with exit code
0. At the end of the run, the CLI reports that the package would be denied by policy:PROMPT>cscf npm install lodash@4.17.21 ... cscf: ⚠ 1 package(s) would be blocked once policy is enforced (audit mode): • pkg:npm/lodash@4.17.21 — would be denied by policy: POLICY_RULE_MATCHED (decisiondecision-id)
You can create one customer managed policy for each account in each AWS Region. For more information, see AWS Continuum quotas.
Step 4: Switch the rule to enforce mode
When you're confident that a rule denies only what you expect, switch it to enforce mode.
-
Save a copy of the policy as
enforce-policy.json, with the rule'senforcementModechanged toENFORCE. Keep the policy'snameand every rule ID the same: an update must use the existing name and include every existing rule. -
Update the policy, using the policy ID from step 3:
PROMPT>aws continuum update-supply-chain-policy \ --regionregion\ --idpolicy-id\ --policy file://enforce-policy.json -
Remove the package and clear npm's cache, so that the next install downloads the package again. The Continuum for software supply chain CLI checks only the packages that the package manager downloads:
PROMPT>npm uninstall lodashPROMPT>npm cache clean --force -
Run the install one more time. The rule now runs in enforce mode, so Continuum for software supply chain denies the package. The CLI blocks the install and returns with exit code
1:PROMPT>cscf npm install lodash@4.17.21 ... cscf: ⛔ blocked 1 package(s): • pkg:npm/lodash@4.17.21 — denied by the verdict service: POLICY_RULE_MATCHED (decisiondecision-id)The decision ID in the output is the one that you pass to
get-package-decisionin step 5.
Step 5: Review the decisions
Each install that you ran created a package decision. List your recent decisions. The output includes the audit decision from step 3 and the deny decision from step 4:
PROMPT>aws continuum list-package-decisions --regionregion{ "decisions": [ { "decisionId": "decision-id", "evaluatedAt": "timestamp", "completedAt": "timestamp", "canonicalPurl": "pkg:npm/lodash@4.17.21", "evaluatedAction": "DENY", "enforcementAction": "DENY", "enforcementMode": "ENFORCE", "reason": "POLICY_RULE_MATCHED" }, { "decisionId": "decision-id", "evaluatedAt": "timestamp", "completedAt": "timestamp", "canonicalPurl": "pkg:npm/lodash@4.17.21", "evaluatedAction": "DENY", "enforcementAction": "ALLOW", "enforcementMode": "AUDIT", "reason": "POLICY_RULE_MATCHED" }, ... ] }
The decision from step 3 has an evaluatedAction of DENY but an
enforcementAction of ALLOW, because its rule ran in audit mode. Your
client acts on enforcementAction. For what each field and reason means, see Decision fields and reasons.
To read one decision again, pass its ID:
PROMPT>aws continuum get-package-decision \ --regionregion\ --decision-iddecision-id
To get a decision for a package without installing it, request one directly:
PROMPT>aws continuum create-package-decision \ --regionregion\ --purl pkg:npm/lodash@4.17.21
For decisions, their evidence, and how long Continuum for software supply chain keeps them, see Reviewing package decisions and evidence.
Step 6: Clean up
To remove the tutorial policy, delete it:
PROMPT>aws continuum delete-supply-chain-policy --regionregion--idpolicy-id
For more about policies, see Managing supply chain policies.
Next steps
Now that you've seen allow, audit, and deny decisions, learn more about Continuum for software supply chain:
-
For an overview of Continuum for software supply chain and how a decision works, see Software supply chain.
-
For the terms and the way Continuum for software supply chain evaluates a package, see AWS Continuum for software supply chain concepts.
-
For the permissions that control access to Continuum for software supply chain, see Identity and access management for AWS Continuum.
-
To run the Continuum for software supply chain CLI in a CI/CD pipeline and act on its exit codes, see Protecting package installs with the Continuum for software supply chain CLI.
-
To let a specific package install despite a rule, see Managing policy exceptions.
-
If something doesn't work as you expect, see Troubleshooting AWS Continuum for software supply chain.