# Repository security features

What every repository checks on its own, and what you turn on.

Every repository has a **Security** section (**Overview**, **Secret scanning**, **Dependencies**,
**Code scanning**), and **Security overview** in the service menu lists the protection and open
alerts of every repository you may read alerts of. Reading alerts needs
`git:ListSecurityAlerts`; closing or dismissing one needs `git:UpdateSecurityAlert`.

| Feature                | Default         | What it does                                                                                                              |
| ---------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Secret push protection | on, every repo  | refuses a push that adds a known credential format; a bypass with a reason becomes an alert                               |
| File size limit        | on (100 MB)     | refuses a push that adds a file over the limit; warns over 50 MB                                                          |
| Dependency alerts      | on, every repo  | checks the default branch's lockfiles against the vulnerability database after a push and daily                           |
| Code scanning          | when you upload | shows the results of any tool that writes SARIF, uploaded from your workflows                                             |
| Security policy        | when you add it | `SECURITY.md` (in `.github/`, the root or `docs/`) is shown on the Security overview to readers with `git:PullRepository` |
| Tag protection         | when you add it | tags matching a pattern can only be created, moved or deleted with `git:PushProtectedTag`                                 |
| Commit statuses        | always          | an external tool reports pass/fail on a commit; a required check can wait for it                                          |

## Change the settings

Turning secret push protection or dependency alerts on or off, or changing the file size limit (1
to 2048 MB), needs `git:UpdateRepository` and is recorded in the audit log. Turning dependency
alerts on starts a scan at once. In the Deutsche Cloud Console, opening the repository's **Security** section
also needs `git:GetRepository` (without it the page is not found).

**Console**
1. In the repository, choose **Security**.
2. Under **Protection**, turn **Secret push protection** or **Dependency alerts** on or off. The
   switch saves at once.
3. (Optional) For **Largest file a push may add**, enter a size in MB (empty for the default of
   100), then choose **Save**.

**CLI**
```sh
dcloud git security update-settings 5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60 --max-file-size-mb 200
```

**API**
```http
PATCH /git/api/repositories/5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60/security/settings
{ "secretPushProtection": true, "maxFileSizeMb": 200 }
```

`maxFileSizeMb: null` returns to the default of 100 MB. The examples use the repository id
`5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60`; `dcloud git repositories list` shows yours.

## Related

- [Handle a push blocked by secret scanning](handle-a-blocked-push.md)
- [Review dependency alerts](review-dependency-alerts.md)
- [Upload code scanning results](upload-code-scanning-results.md)
- [Post a status on a commit](post-a-commit-status.md)
- [Protect tags](protect-tags.md)
