Skip to content

taskrabbit/secret-scanning-review-action

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub GitHub Issues GitHub Issues GitHub Issues GitHub Stars GitHub forks

Latest OpenSSF Scorecard GitHub License

secret-scanning-review-action

Action to provide feedback annotations to the developer when a Secret Scanning alert is initially detected in a PR commit.

The action is intended for private repositories that have GitHub Advanced Security licensed.

Adds a Warning annotation alert to any PR file that has introduced a secret (based on the secret scanning alert initial commit) Secret Scanning Review Workflow File Annotation

Workflow FailOnAlert configuration to turn those Warnings into Errors! Secret Scanning Review Workflow File Annotation

Allowing you additional secret scanning trust->but->verify control in your branch protection rules Secret Scanning Review Workflow Checks

Summary of all secrets from the PR in the Secret Scanning Review workflow job summary Secret Scanning Review Workflow Checks

Comments on the Pull Request Secret Scanning Review Workflow Checks

Overview

This action is used to enhance the Advanced Security Secret Scanning experience with:

Security Model Changes

  • To be clear, this will make Secret Scanning Alerts visible to anyone with Read access to a repo following the View code scanning alerts on pull requests via the workflow annotation access model. This security control level is consistent with the access needed to see any raw secrets already commited to git history!

  • If you do wish to give broader access to Secret Scanning Alerts in the GitHub Advanced Security platform you might consider a custom repository role configuration. With a custom role you can choose to grant View secret scanning results or Dismiss or reopen secret scanning results to any of the base roles with no default alert permissions: Read,Triage or the roles that only see alerts on secrets they have commited: Write,Maintain. The View secret scanning results permission would allow those roles to then be able to view the deep link to the Security Alert column - which is disclosed in the summary.

Configuration Options

token

REQUIRED A GitHub Access Token

  • Classic Tokens
    • repo scope or security_events scope. For public repositories, you may instead use the public_repo scope.
  • Fine-grained personal access token permissions

NOTE:

  • Unfortunately we cannot currently utilize the built in Actions GITHUB_TOKEN due to ommitted permissions on the secret-scanning api. Therefore you must generate a token (PAT or GitHub App) with these permissions, add the token as a secret in your repository, and assign the secret to the workflow parameter. See Also: Granting additional permissions
  • It is worth noting this token will have sensitive data access to return a list of plain text secrets that have been detected in your organization/repository. At this point, a detected secret also implies anyone with read repository access would provide the same level of access to the leaked secret and therefore should be considered compromised.

fail-on-alert

OPTIONAL If provided, will fail the action workflow via non-zero exit code if a matching secret scanning alert is found. Default "false".

fail-on-alert-exclude-closed

OPTIONAL If provided, will handle failure exit code / annotations as warnings if the alert is found and the alert is marked as closed (state: 'resolved'). Default "false".

disable-pr-comment

OPTIONAL If provided, will not put a comment on the Pull Request with a summary of detected secrets. Default "false".

Outputs

N/A

Example usage

Please keep in mind that you need a GitHub Advanced Security license if you're running this action on private repositories.

  1. Add a new YAML workflow to your .github/workflows folder:
name: 'Secret Scanning Review'
on: [pull_request]

jobs:
  secret-scanning-review:
    runs-on: ubuntu-latest
    steps:
      - name: 'Secret Scanning Review Action'
        uses: advanced-security/secret-scanning-review-action@v1
        with:
          token: ${{ secrets.SECRET_SCAN_REVIEW_GITHUB_TOKEN }}
          fail-on-alert: true
          fail-on-alert-exclude-closed: true

Architecture

sequenceDiagram
    autonumber
    participant Repo as Repository
    participant PR as Pull Request
    participant Action as Action Workflow
    participant API_PR as pulls<br/><br/>REST API
    participant API_SECRET as secret-scanning<br/><br/> REST API

    Repo->>PR: Create/Update PR
    PR->>Action: invoke `pull_request` workflow
    Action->>API_PR: GET PR
    Action->>API_PR: GET PR Commits

    loop Commits
        Action->>Action: Build PR Commit SHA list
    end

    Action->>API_SECRET: GET Secret Scanning Alerts

    loop Secret Scanning Alerts
        Action->>API_SECRET: GET Secret Scanning Alert List Locations
        loop Secret Scanning Alert Locations
        Action->>Action:Build List of Alert Initial Location SHAs that are<br/>contained in the PR SHA List (Step 5)
        end
    end

    loop List of matching PR/Alerts
      loop List of Locations for matching PR/Alerts
        Action->>PR:Writes an Annotation to the message log<br/>associated with the file and line/col number.<br/>(Error/Warning based on FailOnAlert setting)
      end
    end

    Note right of PR: Annotations are visible<br/>on the PR Files changed rich diff

    Action->>PR:Writes summary to PR comment and log.<br/>Returns success/failure exit code based on FailOnAlert setting.

    Note right of PR: Fail workflow check<br/>based on FailOnAlert setting.
Loading

Environment Variables

  • Implicit
    • GITHUB_REPOSITORY - The owner / repository name.
    • GITHUB_REF - PR merge branch refs/pull/:prNumber/merge
  • Outputs
    • GITHUB_STEP_SUMMARY - Markdown for each job so that it will be displayed on the summary page of a workflow run (unique for each step in a job)

Dependencies

REST APIs

FAQ

Why Powershell

A few reasons

  1. I was challanged by a coworker during a Python v PowerShell discussion
  2. To demonstrate GitHub Actions flexibility (pwsh is installed by default on the runners!)
  3. Find current pitfalls and work with platform team to improve!
  4. Powershell is cross-platform automation platform with the power of .NET!

About

Action to detect if a secret is initially detected in a PR commit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 100.0%