View a markdown version of this page

Getting started with Continuum for software supply chain - AWS Continuum

Getting started with Continuum for software supply chain

Note

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 need continuum:CreateSupplyChainPolicy, continuum:UpdateSupplyChainPolicy, continuum:DeleteSupplyChainPolicy, continuum:ListPackageDecisions, and continuum: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 package. For what the CLI checks, see Protecting package installs with the Continuum for software supply chain CLI.

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.

  1. 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" } } } ] } } ] }
  2. Create the policy, and note the policy ID in the output for the next steps:

    PROMPT> aws continuum create-supply-chain-policy \ --region region \ --policy file://audit-policy.json { "id": "policy-id", "arn": "policy-arn", "policy": { "name": "block-lodash", ... }, "createdAt": "timestamp", "updatedAt": "timestamp" }
    Note

    If 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.

  3. 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 lodash PROMPT> npm cache clean --force
  4. 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 (decision decision-id)
Note

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.

  1. Save a copy of the policy as enforce-policy.json, with the rule's enforcementMode changed to ENFORCE. Keep the policy's name and every rule ID the same: an update must use the existing name and include every existing rule.

  2. Update the policy, using the policy ID from step 3:

    PROMPT> aws continuum update-supply-chain-policy \ --region region \ --id policy-id \ --policy file://enforce-policy.json
  3. 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 lodash PROMPT> npm cache clean --force
  4. 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 (decision decision-id)

    The decision ID in the output is the one that you pass to get-package-decision in 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 --region region { "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 \ --region region \ --decision-id decision-id

To get a decision for a package without installing it, request one directly:

PROMPT> aws continuum create-package-decision \ --region region \ --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 --region region --id policy-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: