Code-access rules¶
Code-access rules map repositories and package-index packages to required groups. Administrators manage rules through the Hawk API; Hawk stores them in the database.
Code-access enforcement is not enabled yet. Saving rules currently updates recorded policies only. The access behavior below applies once enforcement is enabled.
Set a fallback rule¶
A valid source with no matching rule adds no code-group restriction. To require
a group for all otherwise unmatched repositories and packages, create a * rule:
code-access-public is an ordinary group: only its members satisfy this rule.
Assign it to intended readers. To deny otherwise unmatched sources, use a group
such as code-access-unclassified with no members, then add specific rules for
approved repositories and packages. Specific rules override * for each source.
A run requires all groups from its sources, plus its independent model permissions.
The catch-all applies to recorded source identities. Historical runs without
source links need the optional inventory backfill when rules must cover that
history. Missing or incomplete inventories remain restricted; a catch-all does
not repair them. Finish deploying updated API writers before creating *.
Manage rules¶
All routes require a Hawk administrator.
Read-only credentials cannot change rules, including admin credentials.
If the API's database role is not inspect, the database owner must grant it
EXECUTE ON FUNCTION public.sync_code_group_roles() during provisioning.
| Method | Path | Result |
|---|---|---|
GET |
/code_rules/ |
List all rules, ordered by prefix |
POST |
/code_rules/ |
Create a rule (201) |
PUT |
/code_rules/{pk} |
Replace a rule's prefix and group |
DELETE |
/code_rules/{pk} |
Delete a rule (204) |
Create and update accept this JSON request body:
Use the full code-access-* permission name. Omitted or null groups and unknown
fields are rejected. The name after code-access- starts with a lowercase letter,
contains only lowercase letters, digits, _ and -, and has at most 52 characters.
Responses contain pk (the rule's UUID), url_prefix, and group. A conflicting
prefix returns 409; a missing rule returns 404; invalid input returns 422.
Rule edits automatically update existing runs linked to affected sources.
Deleting a rule falls back to the next matching broader rule, then * if present.
With no match, the source adds no restriction. Deleting a rule does not delete the
group or its memberships. A broad change can update many runs; the rule and their
requirements commit together.
Prefixes and matching¶
Use a source's canonical identity:
- Git: lowercase
host/owner/repository, without a scheme, credentials, port, trailing slash, or clone suffix.git. Hosts and namespaces can cover multiple repositories, including nested namespaces on GitLab. - Package index: the exact normalized package name, such as
inspect-ai, without versions or extras. Names use hyphens in place of dots and underscores. - Catch-all: exactly
*, covering all other valid source identities. Other wildcard patterns such asgithub.com/*are not supported.
The longest specific matching prefix wins for each source; every specific match
takes priority over *. Matching respects / boundaries:
github.com/example/hawk does not match github.com/example/hawk-secret.
| Prefix | Required group |
|---|---|
* |
code-access-public |
github.com/example |
code-access-research |
github.com/example/private-benchmark |
code-access-benchmark |
inspect-ai |
code-access-research |
In this example, private-benchmark requires code-access-benchmark; other
repositories under github.com/example require code-access-research. Other
sources require code-access-public. A run using the private benchmark and an
otherwise unmatched package requires both code-access-benchmark and
code-access-public.
Update rules when repositories are renamed or transferred. A restriction on the old identity does not follow the new name automatically.
Grant access¶
Assign the exact permission named in the rule to intended readers through
the deployment's login provider, such as Okta or Amazon Cognito. For the example
above, assign code-access-benchmark to readers of the private benchmark.
The optional S3 Object Lambda path currently checks model groups in IAM Identity
Center; #1871 adds checks for
code-access-* groups.
For direct database access, code-access-benchmark corresponds to the
code_group_benchmark role.
Creating a rule grants no reader memberships; those must be assigned separately.
Importing results¶
Imports record declared sources and recognized Git origins from logs. Use
--code-sources to supply additional repositories or packages; see the
CLI import instructions.
Declarations describe the uploader's claimed sources, not verified provenance.
When a declaration is omitted or an import identifies no sources, Hawk records
imported-code.invalid/unknown/source. This placeholder follows the same rules,
including *, as other sources. It is separate from an incomplete inventory.
Later uploads retain earlier sources; recorded sources cannot currently be removed
through the CLI or API.