Skip to content
Go to platform

Control network access from jobs

CRACI can control which external services a job may reach and detect supported package downloads for generated SBOMs. Presets cover common software sources and web traffic. Custom sources add private software sources. connections allow other destinations and protocols.

Organization administrators can create reusable configurations under Settings → Runner Templates. Select one with the setup action’s template input. Without a template input, CRACI uses the built-in default template. A workflow that includes an explicit network input replaces the selected template’s network policy for that job.

Add network when you want to restrict outbound connections. Without a network block, CRACI enables every built-in preset and allows connections that do not match a preset. With a network block, CRACI still enables every preset, but blocks unmatched connections unless you set network.default: allow.

CRACI validates the configuration before the job starts. Unknown fields are rejected rather than ignored, so a misspelled setting cannot silently change the policy. CRACI always allows CI job and cache management traffic to GitHub services.

This policy enables every built-in preset. CRACI detects supported package downloads for generated SBOMs, matches other HTTP and HTTPS traffic with the generic-http preset, and blocks other unmatched connections:

- uses: cracicorp/setup@v1
with:
network: |
# Keep every built-in preset and block other unmatched connections.
{}

You do not need to list the presets. They are all enabled when network.presets is omitted.

Presets let CRACI match known software sources and other HTTP and HTTPS traffic. Custom software sources add package detection for private registries. Connections allow destinations that match TLS, TCP, UDP, or ICMP rules. network.default controls connections that match none of these.

ConfigurationPackage detectionOther HTTP and HTTPSOther unmatched connections
Omit networkEnabled for every built-in software sourceMatched by the generic-http presetAllowed
network: {}Enabled for every built-in software sourceMatched by the generic-http presetBlocked
network.default: deny, network.presets: []DisabledBlockedBlocked
network.default: allow, network.presets: []DisabledDirect, end-to-end connections using original server certificatesAllowed

network.presets has three states:

network.presets valueEffective behavior
OmittedEnable every built-in preset
[]Disable every built-in preset
Preset namesEnable only the listed preset names

The following policy enables package detection for PyPI downloads and records GitHub repository access. It blocks other unmatched traffic. The github preset is for repository access; traffic needed to run the GitHub Actions job and manage its cache remains allowed independently.

- uses: cracicorp/setup@v1
with:
network: |
default: deny
presets: [pypi, github]

To disable CRACI’s built-in package detection and matching, select the built-in audit runner template. Connections are direct and end to end, including package, SSH, and Kubernetes traffic. CRACI does not detect packages downloaded by these jobs.

jobs:
integration:
runs-on: [craci]
steps:
- uses: cracicorp/setup@v1
with:
template: audit

For a one-job override, the equivalent network configuration is still default: allow with presets: [].

Add a TLS connection for the API server hostname and port. The client certificate remains between kubectl and the Kubernetes API server.

- uses: cracicorp/setup@v1
with:
network: |
connections:
- tls:
serverNamePatterns: [kube-apiserver.example.com]
ports: [6443]
- name: Access Kubernetes
env:
KUBECONFIG: ${{ runner.temp }}/kubeconfig
run: kubectl get namespaces

Your kubeconfig must use kube-apiserver.example.com:6443. The alpn field is optional. The hostname must resolve normally from the job. For a kubeconfig that connects directly to an IP address, use cidrs instead of serverNamePatterns.

Custom sources extend the built-in presets. This example allows a private Python package index in addition to every built-in source:

- uses: cracicorp/setup@v1
with:
network: |
default: deny
sources:
- pypi:
urls:
- https://packages.example.com/api/pypi/python/simple

Each URL is an allowed package endpoint. If your registry exposes multiple independent endpoints, list each URL explicitly.

Add the complete registry URL to the setup action. For example, PyPI and NPM:

- uses: cracicorp/setup@v1
with:
network: |
default: allow
sources:
- pypi:
urls:
- https://artifactory.example.com/artifactory/api/pypi/pypi-repository/simple
- npm:
urls:
- https://artifactory.example.com/artifactory/api/npm/npm-repository

Replace the hostname and repository keys with your Artifactory values. Write the URLs literally: repository variables such as ${{ vars.JF_URL }} are not currently supported in the setup action’s network input.

After checking out the repository and setting up Python, install JFrog CLI, configure its pip resolver, and install the current project:

- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ vars.JF_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- name: Configure pip
run: jf pip-config --global=true --repo-resolve=pypi-repository
- name: Install dependencies
run: jf pip install .

Set JF_URL to the Artifactory base URL, such as https://artifactory.example.com. Repository variables and secrets are supported in the JFrog action’s environment. Replace pypi-repository in the jf pip-config command with your PyPI repository key.

Example: Install from npm without JFrog CLI

Section titled “Example: Install from npm without JFrog CLI”

Configure npm to use the same registry URL from the setup action:

- name: Configure npm
env:
ARTIFACTORY_NPM_TOKEN: ${{ secrets.ARTIFACTORY_NPM_TOKEN }}
run: |
npm config set registry https://artifactory.example.com/artifactory/api/npm/npm-repository
npm config set //artifactory.example.com/artifactory/api/npm/npm-repository/:_authToken "$ARTIFACTORY_NPM_TOKEN"

The npm config commands are one way to configure the registry. You can instead use an .npmrc file or another package-manager configuration mechanism, as long as it selects the same URL. Store the access token in the ARTIFACTORY_NPM_TOKEN GitHub Actions secret. CRACI does not send the token to another host when package metadata refers to an external archive.

Use a TCP connection for services that do not use TLS, such as a database on a private network:

- uses: cracicorp/setup@v1
with:
network: |
default: deny
connections:
- tcp:
hostPatterns: [postgres.internal.example.com]
cidrs: [10.60.0.0/16]
ports: [5432]

For TCP connections, a hostname or CIDR match is sufficient when both are present. The destination port must also match.

Validation errors identify unknown fields, missing required fields, and entries that contain more than one software source or connection type.

SettingRequiredDefaultDescription
defaultNodenyControls unmatched traffic when network is configured. allow permits unmatched outbound connections.
presetsNoAll presetsSelects built-in software sources and other HTTP and HTTPS traffic. An empty list disables all presets.
sourcesNoNoneAdds private or custom software sources. Each item contains exactly one source type.
connectionsNoNoneAdds TLS, TCP, UDP, or ICMP destinations. Each item contains one connection type.

All source URLs must use HTTP or HTTPS.

SourceSettingRequiredDefaultDescription
pypiurlsYesNo defaultOne or more Python package index URLs.
npmurlsYesNo defaultOne or more npm registry URLs.
apturlsYesNo defaultOne or more Debian-style repository URLs.
aptpurlNamespaceNoNonePackage URL namespace recorded for packages from this source.
apkurlsYesNo defaultOne or more Alpine repository URLs.
golangurlsYesNo defaultOne or more Go module proxy URLs.
nixurlsYesNo defaultOne or more Nix binary cache URLs.
cargoindexUrlYesNo defaultCargo index URL.
cargodownloadUrlYesNo defaultCrate download URL.
sources:
- oci:
urls: [https://registry.example.com]
# default: ["**"] - Allows all repositories
repositoryPatterns: ["platform/**", "third-party/*"]
operations: [pull]
SettingRequiredDefaultDescription
urlsYesNo defaultRegistry endpoints. Provide at least one URL.
repositoryPatternsNo["**"]Limits access to matching repositories.
operationsYesNo defaultAllowed operations: pull, push, or delete. Provide at least one.
sources:
- git:
# default: ["**"] - Allows all repositories
repositoryPatterns: ["https://git.example.com/platform/**"]
https:
- baseUrl: https://git.example.com
ssh:
- host: git.example.com
port: 22
user: git
upstreamKnownHosts:
- "git.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA..."

At least one HTTPS or SSH transport is required.

SettingRequiredDefaultDescription
repositoryPatternsNo["**"]Limits access to matching repositories.
https[].baseUrlFor HTTPSNo defaultBase URL of an allowed Git server.
ssh[].hostFor SSHNo defaultHostname of an allowed SSH server.
ssh[].portFor SSHNo defaultSSH server port.
ssh[].userNoAny userRestricts the SSH username when set.
ssh[].upstreamKnownHostsFor SSH connectivityNo trusted host keysTrusted SSH host keys. The configuration is valid without this field, but the connection fails unless a host key matches.
connections:
- tls:
# Either cidrs or serverNamePatterns needs to be set.
serverNamePatterns: [api.example.com]
cidrs: [10.50.0.0/16]
ports: [443]
# default: no ALPN filtering
alpn: [h2]
SettingRequiredDefaultDescription
serverNamePatternsOne selector requiredNoneMatches the TLS server name.
cidrsOne selector requiredNoneMatches the destination IP address.
portsYesNo defaultAllowed destination ports. Provide at least one.
alpnNoNo ALPN filteringWhen set, at least one protocol offered by the client must match.

Set serverNamePatterns, cidrs, or both. When both are set, both selectors and the destination port must match.

SettingRequiredDefaultDescription
hostPatternsOne selector requiredNoneMatches the destination hostname.
cidrsOne selector requiredNoneMatches the destination IP address.
portsNoAll portsLimits the allowed destination ports.

Set hostPatterns, cidrs, or both. When both are set, either selector may match. When ports is set, the destination port must also match. A TCP rule takes precedence when TCP and TLS rules match the same connection.

SettingRequiredDefaultDescription
cidrsYesNo defaultMatches IPv4 destination addresses.
portsNoAll portsLimits the allowed destination ports.
SettingRequiredDefaultDescription
cidrsYesNo defaultMatches IPv4 destination addresses.

All presets are enabled when presets is omitted. A non-empty presets list replaces that set. The following table is the complete list of accepted preset names.

PresetAllows
generic-httpHTTP and HTTPS traffic not matched by a more specific preset
pypiPyPI index and package files
npmPublic npm registry and its Yarn mirror
alpineAlpine package repositories
debianDebian package repositories
ubuntuUbuntu archive, security, ports, and snapshot repositories
cargocrates.io index and crate downloads
golangPublic Go module proxy
fontsGoogle Fonts, Adobe Fonts, Bunny Fonts, and Fontshare
cache-nixos-orgcache.nixos.org and binary caches on *.cachix.org
dockerhubDocker Hub pulls and authentication
ghcrGitHub Container Registry pulls
quayQuay container registry pulls
gcrGoogle Container Registry pulls
ecr-publicAmazon ECR Public pulls
githubGitHub repositories over HTTPS and SSH
gitlabGitLab repositories over HTTPS and SSH
docker-aptDocker’s APT repositories
nodesourceNodeSource APT repositories
raspbianRaspbian repositories
yoctoYocto downloads and Git repositories
openembeddedOpenEmbedded Git repositories
bitbucketBitbucket Git repositories over SSH
googlesourceChromium’s Google Source repository over HTTPS and Google Source repositories over SSH

Host patterns may be exact hostnames or begin with one *. wildcard. For example, *.example.com matches subdomains of example.com.

OCI repository patterns match the repository name without the registry hostname. They use * within one path segment and ** across path segments. For example, platform/* matches one segment below platform, while platform/** matches repositories at any depth below it.

Git repository patterns match the full HTTPS repository URL. Include the server in the pattern, such as https://git.example.com/platform/**. SSH access is restricted by the configured host, port, and optional user fields.

Use the versioned JSON Schema for YAML completion and validation in your editor.