--- title: "Network policy reference" description: "Fields and matching rules for the cracicorp/setup network input" source: "https://docs.craci.com/reference/network-policy/" --- Configure these fields in the `network` input of `cracicorp/setup@v1`. For examples and available presets, see [Control network access from jobs](/guides/setup-action-network/). Validation errors identify unknown fields, missing required fields, and entries that contain more than one software source or connection type. ### Network policy | Setting | Required | Default | Description | | ------------- | -------- | ----------- | -------------------------------------------------------------------------------------------------------- | | `default` | No | `deny` | Controls unmatched traffic when `network` is configured. `allow` permits unmatched outbound connections. | | `presets` | No | All presets | Selects built-in software sources. An empty list disables all presets. | | `sources` | No | None | Adds private or custom software sources. Each item contains exactly one source type. | | `connections` | No | None | Adds TLS, TCP, UDP, or ICMP destinations. Each item contains one connection type. | ### Package sources All source URLs must use HTTP or HTTPS, without embedded credentials, query strings, or fragments. | Source | Setting | Required | Default | Description | | ---------- | --------------- | -------- | ---------- | ------------------------------------------------------------- | | `npm` | `urls` | Yes | No default | One or more npm registry URLs. | | `rubygems` | `urls` | Yes | No default | One or more RubyGems registry URLs. | | `rustup` | `urls` | Yes | No default | Rust toolchain download endpoints. | | `apt` | `urls` | Yes | No default | One or more Debian-style repository URLs. | | `apt` | `purlNamespace` | No | None | Package URL namespace recorded for packages from this source. | | `apk` | `urls` | Yes | No default | One or more Alpine repository URLs. | | `golang` | `urls` | Yes | No default | One or more Go module proxy URLs. | | `cargo` | `indexUrl` | Yes | No default | Cargo index URL. | | `cargo` | `downloadUrl` | Yes | No default | Crate download URL. | ### OCI registries ```yaml sources: - oci: urls: [https://registry.example.com] # default: ["**"] - Allows all repositories repositoryPatterns: ["platform/**", "third-party/*"] operations: [pull] ``` | Setting | Required | Default | Description | | -------------------- | -------- | ---------- | ---------------------------------------------------------------------- | | `urls` | Yes | No default | Registry endpoints. Provide at least one URL. | | `repositoryPatterns` | No | `["**"]` | Limits access to matching repositories. | | `operations` | Yes | No default | Allowed operations: `pull`, `push`, or `delete`. Provide at least one. | ### Git sources ```yaml 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. :::caution[Git policies are not a complete HTTPS allowlist] Configuring an HTTP(S) Git source also enables smart-Git HTTPS requests to other hosts. Those fallback requests are not constrained by the configured source's `repositoryPatterns`. Do not rely on these patterns as a complete Git egress restriction. ::: | Setting | Required | Default | Description | | -------------------------- | -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------- | | `repositoryPatterns` | No | `["**"]` | Limits access to matching repositories. | | `https[].baseUrl` | For HTTPS | No default | HTTP(S) base URL of a configured Git server. | | `ssh[].host` | For SSH | No default | Hostname of an allowed SSH server. | | `ssh[].port` | For SSH | No default | SSH server port. | | `ssh[].user` | No | Any user | Accepted but not enforced; do not rely on this field to restrict usernames. | | `ssh[].upstreamKnownHosts` | For SSH connectivity | No trusted host keys | Trusted SSH host keys. The configuration is valid without this field, but the connection fails unless a host key matches. | ### TLS connections ```yaml 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] ``` | Setting | Required | Default | Description | | -------------------- | --------------------- | ----------------- | ----------------------------------------------------------------- | | `serverNamePatterns` | One selector required | None | Matches the TLS server name. | | `cidrs` | One selector required | None | Matches the destination IP address. | | `ports` | Yes | No default | Allowed destination ports. Provide at least one. | | `alpn` | No | No ALPN filtering | When 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, along with any ALPN filter. Without CIDRs, the TLS server name must also have a CRACI-observed DNS binding to the destination IP. ### TCP connections | Setting | Required | Default | Description | | -------------- | --------------------- | --------- | -------------------------------------------------- | | `hostPatterns` | One selector required | None | Matches recorded DNS names for the destination IP. | | `cidrs` | One selector required | None | Matches the destination IP address. | | `ports` | No | All ports | Limits 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. For hostname-only TCP rules, explicitly list ports: omitted ports currently do not enable hostname matching on non-443 connections. Use explicit IPv4 prefixes such as `192.0.2.1/32` for TCP, UDP, and ICMP CIDRs. On port 443, TLS rules are matched before TCP fallback. On other intercepted TCP ports, TCP classification precedes TLS inspection. Required platform sources can take precedence over passthrough rules. Overlapping passthrough rules can bypass package detection and source-level repository or operation restrictions. ### UDP connections | Setting | Required | Default | Description | | ------- | -------- | ---------- | ------------------------------------- | | `cidrs` | Yes | No default | Matches IPv4 destination addresses. | | `ports` | No | All ports | Limits the allowed destination ports. | ### ICMP connections | Setting | Required | Default | Description | | ------- | -------- | ---------- | ----------------------------------- | | `cidrs` | Yes | No default | Matches IPv4 destination addresses. | ## Pattern matching Host patterns may be exact hostnames or begin with one `*.` wildcard. For example, `*.example.com` matches one or more subdomain levels, but not `example.com` itself. Hostname matching is case-insensitive; repository matching is case-sensitive. 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 repository identity. Include the server in the pattern, such as `https://git.example.com/platform/**`. SSH requests are also checked against `repositoryPatterns`, using HTTPS-form and SSH-origin identities. SSH transport restrictions include `host` and `port`; the optional `user` field is not enforced. Restrict users through the upstream server's authentication and permissions instead.