CodeCargo logo

Security

Baselines

A baseline is what one repository, workflow or job was seen connecting to: each destination, with the ports and protocols it used, and how many connections and runs it appeared in. CargoWall builds baselines from your runs, in audit or enforce, so you can see what a workflow needs before you write its policy, and convert what it learned into one.

How Baselines Work

CargoWall creates baselines on its own the first time a job that runs the CargoWall step reports, at three levels:

ScopeLearns fromNamed
RepositoryEvery workflow in the repository[auto] repo:<repository>
WorkflowEvery job in one workflow file[auto] workflow:<repository>/<path>
Workflow JobOne job in a workflow[auto] job:<repository>/<path>/<job>

A new baseline is Learning: each run adds the destinations it saw. It becomes Stable once it has seen its target number of runs, 25 for the baselines CargoWall creates, and everything it learns from has run at least once:

  • A repository baseline waits for every default-branch workflow that reported CargoWall traffic within your plan's CargoWall history.
  • A workflow baseline waits for every such job in the workflow.
  • A job baseline needs only its target.

So a baseline can show 25/25 and still be learning, until a workflow or job that rarely runs comes round. CargoWall checks every 15 minutes. A run only counts if the job made at least one connection.

A stable baseline stops learning. When a workflow's needs change, recompute its baseline.

Notifications

Baselines ready to enforce tells you when repository baselines reach their target, and Stalled baselines when a repository baseline still learning has had no run for 14 days. Workflow and job baselines don't notify. See Notifications.


The Baselines Tab

The Baselines tab lists your organization's baselines with their scope, status and progress: how many of its target runs a learning baseline has seen, or how many runs a stable one learned from. A repository's or workflow's CargoWall tab lists just its own, and the Policy Manager's Chain view shows them at each level.

CargoWall Baselines tab: the header counts 3 baselines, 1 repository, 2 workflows and 0 jobs, with a Policy Manager button. Baselines by scope lists the stable ledger-service · ci workflow baseline at 20 runs, and checkout-web · ci and search-etl still learning at 13/20 and 8/30

Expand a baseline to see what it learned: each destination with its port and protocol, and its connection and run counts. In the Policy Manager's Chain view, Allow on an entry adds it to a policy with the same port and protocol. See Allow a Destination.

An expanded ledger-service · ci baseline: an AI Policy Advisor card with a Generate button above six baseline entries, including registry.npmjs.org, github.com, api.stripe.com, sonarcloud.io, hooks.slack.com and ghcr.io, each on 443/TCP with connection and run counts

Anyone in the organization can see baselines for the repositories they can read. Only an organization admin can create, rename, recompute, convert or delete one.

Create a Baseline

To learn from a different number of runs, or start from runs that already happened:

  1. Open a repository's or workflow's CargoWall tab and switch to Baselines.
  2. Click Create baseline.
  3. Enter a Name, the Learning Run Target, and, to start from history, Seed from Last Runs with how many recent runs to learn from.
  4. Click Submit.

When a repository or workflow has no baselines, anyone but an organization admin is told to ask one to create a baseline.

Baseline Actions

Each baseline's options menu (⋯) has:

ActionWhat it does
RenameChanges the baseline's name
RecomputeRelearns the baseline from recent runs
Convert to PolicyCreates a policy from what the baseline learned. Only for Stable baselines
DeleteRemoves the baseline, after you confirm

Recompute a Baseline

Recompute clears what the baseline learned and relearns it from the most recent runs of its repository, workflow or job. Enter the Run Count to learn from, then click Submit. The baseline goes back to Learning, and becomes Stable straight away when the count reaches its target and everything it learns from has run.

Convert a Baseline to a Policy

  1. Open a stable baseline's options menu (⋯) and choose Convert to Policy.
  2. Enter a Policy Name. It starts as the baseline's name followed by "Policy".
  3. Click Submit. Each destination the baseline learned becomes an allow rule, with its ports. An IP address becomes a /32 CIDR block. A destination the baseline saw only as a DNS lookup gets a rule with no ports, which allows every port, and auto-allowed hosts are included.
  4. Assign the new policy where it should apply. Converting doesn't assign it.

Review the rules before you enforce. A baseline allows exactly what it saw, including anything a compromised dependency reached while it was learning.


AI Policy Advisor

The AI Policy Advisor writes a minimal policy from a workflow's or job's baseline. It needs a plan that includes AI features.

  1. Expand a workflow or job baseline. The AI Policy Advisor card is at the top.
  2. Click Generate. An AI chat opens in the sidebar. The advisor reads the baseline and the workflow file, and proposes an allow list, using wildcards sparingly, whether to turn on sudo lockdown, and why.
  3. Refine the proposal in the chat. Mention other workflows or jobs with @ to cover them too.
  4. Review it in the Policy Manager: select the workflow or job and open Proposed, or follow Review in Policy Manager from the card. For a job baseline, that link opens the Policy Manager with nothing selected, so select the job under Entities. Each proposal has Dismiss and Apply. To reopen its conversation, click the thread name after From thread:. A proposal from another member's conversation reads Proposed by and their name. At the foot of the Entities tab, Dismiss All and Apply All act on every waiting proposal, for every workflow and job.
Policy Manager Proposed view for the ledger-service ci workflow: one AI proposal from the thread Propose minimum-safe egress policy with Dismiss and Apply, sudo lockdown to be disabled, allow rules for api.stripe.com, sonarcloud.io and hooks.slack.com on 443/tcp, the advisor's reasons, and the observed baseline entries below. The Entities tree marks ci as having a proposal, above Dismiss All and Apply All

Apply replaces every rule in the workflow's or job's default policy with the proposal, and sets its sudo lockdown when the proposal includes it. Assigned and inherited policies aren't changed. Applying needs the same access as changing that default policy.

CargoWall Baselines - Docs