Skip to content

Commit ab18cbb

Browse files
authored
Merge pull request #38 from dcodx/copilot/add-tag-settings-to-readme
Add tag protection policy documentation to repository.readme.md
2 parents 748b898 + 81403f5 commit ab18cbb

2 files changed

Lines changed: 141 additions & 0 deletions

File tree

policies/repository.readme.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,98 @@ protected_branches:
6161
- `allow_fork_syncing`: if set to `true`, the branch can be synced with the upstream repository.
6262

6363

64+
## Tag Protection
65+
66+
Tag protection is a way to protect important version tags and releases from unauthorized modifications or deletions. The policy checks whether the tag protection settings specified are applied to the repository using GitHub repository rulesets.
67+
68+
[GitHub Repository Rulesets for Tags](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets)
69+
70+
```yml
71+
tags:
72+
enforcement: active # disabled | active | evaluate
73+
target: tag # fixed for tag rules so we can also not specify it here but fix it in code
74+
75+
scope:
76+
include:
77+
- "v*" # e.g., protect all version tags
78+
# - "~ALL" # special token: all tags
79+
exclude: [] # patterns to exclude, e.g., ["v*-rc*", "v*-beta*"]
80+
81+
operations: # who can perform actions on matching tags
82+
create: restricted # allowed | restricted (restricted = bypass-only)
83+
update: restricted
84+
delete: restricted
85+
86+
naming: # optional: constrain tag names
87+
enabled: true
88+
operator: regex # starts_with | ends_with | contains | regex
89+
pattern: "^v\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
90+
negate: false # true = pattern disallowed
91+
92+
bypass: # actors allowed to bypass protections
93+
organization_admins: always # always | exempt
94+
teams:
95+
- id: 1234567 # example team id
96+
mode: always # always | exempt
97+
integrations:
98+
- id: 987654 # GitHub App id
99+
mode: always
100+
repository_roles:
101+
- id: 3 # e.g., Maintainer role id
102+
mode: always
103+
deploy_keys:
104+
allow: true # DeployKeys can bypass when true
105+
mode: always
106+
```
107+
108+
`tags` configuration has the following settings:
109+
110+
- `enforcement` (**mandatory**): the enforcement level for the tag ruleset.
111+
- `disabled`: the ruleset is disabled and not enforced.
112+
- `active`: the ruleset is actively enforced and will block non-compliant operations.
113+
- `evaluate`: the ruleset runs in evaluation mode (logs violations without blocking).
114+
115+
- `target` (**optional**): should always be `tag` for tag rulesets. This is typically fixed in code and doesn't need to be specified.
116+
117+
- `scope`: defines which tags are protected by the ruleset.
118+
- `include`: a list of tag patterns to protect. Supports wildcards (e.g., `v*` for all version tags) and the special token `~ALL` to protect all tags.
119+
- `exclude`: a list of tag patterns to exclude from protection (e.g., `["v*-rc*", "v*-beta*"]` to exclude release candidates and beta versions).
120+
121+
- `operations`: defines who can perform operations on protected tags.
122+
- `create`: controls tag creation. Set to `restricted` to allow only bypass actors to create tags, or `allowed` for unrestricted creation.
123+
- `update`: controls tag updates. Set to `restricted` to allow only bypass actors to update tags, or `allowed` for unrestricted updates.
124+
- `delete`: controls tag deletion. Set to `restricted` to allow only bypass actors to delete tags, or `allowed` for unrestricted deletion.
125+
126+
- `naming` (**optional**): constrains tag names using pattern matching.
127+
- `enabled`: set to `true` to enable naming constraints.
128+
- `operator`: the pattern matching operator to use.
129+
- `starts_with`: tag name must start with the pattern.
130+
- `ends_with`: tag name must end with the pattern.
131+
- `contains`: tag name must contain the pattern.
132+
- `regex`: tag name must match the regular expression pattern.
133+
- `pattern`: the pattern or regular expression to match against tag names. For semantic versioning, use: `"^v\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"`.
134+
- `negate`: if set to `true`, the pattern is disallowed (inverts the match).
135+
136+
- `bypass` (**optional**): defines actors who can bypass tag protection rules.
137+
- `organization_admins`: bypass mode for organization administrators.
138+
- `always`: organization admins can always bypass the rules.
139+
- `exempt`: organization admins are not exempt and must follow the rules.
140+
- `teams`: a list of teams that can bypass the rules.
141+
- `id`: the team ID (numeric).
142+
- `mode`: `always` (can bypass) or `exempt` (cannot bypass).
143+
- `integrations`: a list of GitHub Apps that can bypass the rules.
144+
- `id`: the GitHub App ID (numeric).
145+
- `mode`: `always` (can bypass) or `exempt` (cannot bypass).
146+
- `repository_roles`: a list of repository roles that can bypass the rules.
147+
- `id`: the repository role ID (e.g., 3 for Maintainer).
148+
- `mode`: `always` (can bypass) or `exempt` (cannot bypass).
149+
- `deploy_keys`: configuration for deploy keys.
150+
- `allow`: set to `true` to allow deploy keys to bypass protections, `false` to deny.
151+
- `mode`: `always` (can bypass) or `exempt` (cannot bypass).
152+
153+
**Best Practice**: Use tag protection to secure release tags, enforce semantic versioning, and prevent accidental deletion or modification of important version markers.
154+
155+
64156
## File Disallow
65157

66158
The `file_disallow` policy checks if sensitive files that should not be present in the repository are found. This helps prevent accidental commits of credentials, API keys, and other sensitive information.

policies/repository.threats.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,55 @@ webhooks:
141141
- Endpoint compromise
142142
143143
144+
### Unauthorized modification or deletion of release tags
145+
146+
A malicious actor could modify or delete release tags in the repository, potentially compromising the integrity of versioned releases, breaking deployments, or enabling supply chain attacks by manipulating which code versions are considered official releases.
147+
148+
#### Security controls
149+
- Restrict who can create, update, or delete tags using repository rulesets
150+
- Enforce naming conventions for version tags to ensure consistency
151+
- Define bypass actors who are authorized to manage protected tags
152+
- Use evaluation mode to test tag protection rules before enforcement
153+
- Limit tag operations to specific teams or roles
154+
155+
#### Gitarmor policy configuration
156+
```yml
157+
tags:
158+
enforcement: active
159+
target: tag
160+
scope:
161+
include:
162+
- "v*"
163+
exclude:
164+
- "v*-rc*"
165+
- "v*-beta*"
166+
operations:
167+
create: restricted
168+
update: restricted
169+
delete: restricted
170+
naming:
171+
enabled: true
172+
operator: regex
173+
pattern: "^v\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
174+
negate: false
175+
bypass:
176+
organization_admins: always
177+
repository_roles:
178+
- id: 3
179+
mode: always
180+
```
181+
182+
#### SLSA.dev threats
183+
- [(A) Submit unauthorized change](https://slsa.dev/spec/v1.0/threats-overview) - Unauthorized tag modifications can point to malicious code
184+
- [(F) Upload modified package](https://slsa.dev/spec/v1.0/threats) - Manipulated tags can cause incorrect artifacts to be published
185+
186+
#### MS DevOps threat matrix
187+
- [3. Persistence](https://www.microsoft.com/en-us/security/blog/2023/04/06/devops-threat-matrix/)
188+
- Changes in repository (tag manipulation)
189+
- [4. Privilege escalation](https://www.microsoft.com/en-us/security/blog/2023/04/06/devops-threat-matrix/)
190+
- Unauthorized release creation or modification
191+
192+
144193
### Sensitive files committed to the repository
145194
146195
Developers may accidentally commit sensitive files containing credentials, API keys, passwords, or other confidential information to the repository. Files like `.env`, configuration files, or credential files can expose the application and infrastructure to unauthorized access.

0 commit comments

Comments
 (0)