> For the complete documentation index, see [llms.txt](https://help.nightfall.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.nightfall.ai/github/policies/recommended-policies-for-github.md).

# Recommended Policies for GitHub

Recommended Nightfall for GitHub policies for secrets, sensitive data, and public repositories, and how to pair them with endpoint git push monitoring.

**Audience:** Security teams protecting source code and secrets in GitHub.

Nightfall protects code in two places, and you get the best coverage by using both:

* **Nightfall for GitHub** (this page) scans what lands in your GitHub organizations. It finds secrets and sensitive data in every commit, on every branch, and notifies the developer and your security team.
* **Nightfall Endpoint Exfiltration** watches where code goes from a managed laptop. It alerts when a developer pushes code to a repository outside your approved list, and blocks source code and secrets from being uploaded to personal or risky destinations. See [Pair with endpoint protection](#pair-with-endpoint-protection).

{% hint style="info" %}
Nightfall for GitHub does not block pushes, revert commits, or change branch protection. It detects sensitive data, notifies people, and tracks the event until it is resolved.
{% endhint %}

## Before you create policies

* A GitHub organization owner installs Nightfall on each GitHub organization you want to protect. Choose **All repositories** so new repositories are covered automatically.
* Nightfall scans code pushed to any branch, in real time. It scans commit diffs and changed files. It does not scan issues, pull request descriptions, comments, or wikis.
* Nightfall does not monitor developers' personal GitHub accounts or personal repositories.
* For the permissions Nightfall requests and how organization and repository scoping work, see the SaaS App Permissions Reference.

| Risk                                       | Recommended policy               | Action                         |
| ------------------------------------------ | -------------------------------- | ------------------------------ |
| A secret is committed to a repository      | Policy 1: Secrets in code        | Alert and notify the developer |
| Customer data is committed to a repository | Policy 2: Sensitive data in code | Alert and open a ticket        |
| A public repository exposes sensitive data | Policy 3: Public repositories    | Alert with a higher risk score |

## Policy 1: Secrets in code

**Why:** A key committed to Git stays in the repository history, and in every clone, until it is rotated.

* **Scope:** All repositories in each organization.
* **Detection rules:** Credentials and API keys, passwords, and cryptographic private keys.
* **Notifications:** Notify the developer by email or Slack. Send an admin alert to your security channel.
* **End-user remediation:** Turn on **Report as False Positive with Business Justification** so developers can flag test keys.
* **What to do with a finding:** Rotate the key first. Removing the commit does not make a leaked key safe. Then remove it from history if needed. See Remediation on Nightfall for GitHub.

## Policy 2: Sensitive data in code

**Why:** Real customer records end up in test fixtures, seed files, logs, and config files.

* **Scope:** All repositories.
* **Detection rules:** PII, PCI, and PHI.
* **Notifications:** Send an admin alert. From the event, use **Send to Jira** to assign cleanup to the repository owner.

## Policy 3: Public repositories

**Why:** Anything in a public repository is exposed to the internet the moment it is pushed.

* **Scope:** Public repositories only.
* **Detection rules:** The same rules as Policies 1 and 2.
* **Risk score:** Set a higher risk score than your private repository policies so these events rise to the top of the queue.
* **Notifications:** Use email or Slack.

{% hint style="warning" %}
Do not use GitHub comment notifications on public repositories. GitHub comments include a snippet of the finding, and on a public repository those comments are public.
{% endhint %}

## Reduce noise on every GitHub policy

* Exclude test fixtures, vendored dependencies, and generated files with directory exclusions (for example `^test/fixtures/` or `^vendor/`). See Use Regular Expressions to Exclude GitHub Directories.
* Exclude file types that never hold real secrets, such as lock files.
* Exclude repositories that exist only for testing by name pattern.

## Scan history

Live scanning only covers new pushes. Run a historical scan of all branches when you first connect GitHub, and again before you make any repository public. See [GitHub audit](https://help.nightfall.ai/audit/github-audit/overview).

## Pair with endpoint protection

Nightfall for GitHub only sees repositories in your organizations. To see code leaving through other paths, add these Nightfall Endpoint Exfiltration and AI Agent Security policies:

| Policy                              | What it does                                                                                                                   | Action                         |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
| Git push to unapproved repositories | Alerts when code is pushed from a managed laptop to a repository outside your approved list, such as a personal GitHub account | Alert only. The push completes |
| Source code uploads                 | Stops source code from being uploaded through the browser or synced to personal cloud storage                                  | Block                          |
| Secrets on the endpoint             | Stops API keys, passwords, and private keys from being pasted or uploaded anywhere                                             | Block                          |
| Secrets in AI coding agents         | Stops secrets from being sent to, or run by, Claude Code, Cursor, and VS Code Copilot                                          | Block                          |
| Remote MCP tools                    | Limits which remote tools coding agents can call, and removes write and delete tools                                           | Disable tools                  |

For configuration details, see [Recommended Policy Configurations](https://help.nightfall.ai/data-exfiltration-prevention/exfiltration_endpoint/policies/recommended-policy-configurations) (Recommendations 1 and 2) and [Hook policy recommendations](https://help.nightfall.ai/data-exfiltration-prevention/ai-agent-security/ai-governance/hook-policy-recommendations) (policies 1 and 5).

## Roll out in stages

1. **Week 1:** Turn on Policies 1 and 3. Secret detection is precise, so it is safe to alert right away.
2. **Weeks 1 and 2:** Turn on Policy 2 and add exclusions based on what you see.
3. **Ongoing:** When you create a new GitHub organization, install Nightfall on it and add it to each policy's scope.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.nightfall.ai/github/policies/recommended-policies-for-github.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
