This action is designed to be used to map GHAS alerts between original repository and a copy of it. It will update the GHAS alert state of the target repository to match the original repository.
The action is designed to be used in a workflow that is triggered either manually or by a schedule.
The primary use case for this is when you are migrating a repository from one organization to another, and you want to ensure that the GHAS alert state is consistent between the original repository and the new repository. This avoids the need for repository owners/maintainers to go over already triaged and resoled alerts.
original_repository
(required): Full name of the original repository - organization/repository.original_endpoint
(optional, default:https://api.github.com
): Endpoint for the original repository.original_token
(required): GitHub Access Token for the original repository.target_repository
(required): Full name of the target repository - organization/repository.target_endpoint
(optional, default:https://api.github.com
): Endpoint for the target repository.target_token
(required): GitHub Access Token for the target repository.dry_run
(required, default:true
): Dry run the action without making any changes.alert_types
(optional, default:all
): Comma separated list of alert types to process. Valid values areall
,secret-scanning
,code-scanning
, anddependabot
.matchinglevel
(optional, default:exact
): Valid values areexact
orloose
.
code-scanning
and dependabot
alert types are not supported
yet.
report_file
: The path to the report file that contains the results of the action. This file will be in thereports
directory of the repository.
- The action works by first getting a list of all the GHAS alerts in the original repository.
- It then gets a list of all the GHAS alerts in the target repository.
- It then compares the two lists of alerts and identifies the matches. The matching works differently per alert type. Documented in the Matching Alert Criteria section.
- For each match, it updates the state of the alert in the target repository to
match the state of the alert in the original repository. The state is
determined by the
state
property of the alert. The valid states areopen
,resolved
, anddismissed
.
- If the state of the alert in the original repository is different from the state of the alert in the target repository, the action will update the state of the alert in the target repository to match the state of the alert in the original repository.
- If the state of the alert in the original repository is the same as the state of the alert in the target repository, the action will do nothing.
The alerts are a match when the following criteria are met:
- Matching level
exact
: The alerts are a match when the following criteria are met:- The secret provider is the same.
- The secret type is the same.
- The secret itself is the same.
- The number of locations where the secret is found is the same.
- Matching level
loose
: The alerts are a match when the following criteria are met:- The secret provider is the same.
- The secret type is the same.
- The secret itself is the same.
After you've cloned the repository to your local machine or codespace, you'll need to perform some initial setup steps before you can develop your action.
-
🛠️ Install the dependencies
npm install
-
🏗️ Package the TypeScript for distribution
npm run bundle
-
✅ Run the tests
$ npm test ...
You can use the local-action
command to run the action locally.
-
Edit .env file and add the required inputs. You can copy the .env.example file and update the values as needed.
-
Run the action locally
npx local-action . src/main.ts .env
You can use the action in a workflow in any repository. The following is an example of a workflow that uses the action:
name: Update GHAS alert state
...
jobs:
update_ghas_alert_state:
runs-on: ubuntu-latest
steps:
...
- name: Update GHAS alert state
id: update_ghas_alert_state
uses: theztefan/ghas-alert-mapper@main
with:
original_repository: octocat/original-repo
original_token: ${{ secrets.ORIGINAL_TOKEN }}
target_repository: octocat/target-repo
target_token: ${{ secrets.TARGET_TOKEN }}
dry_run: 'false'
alert_types: 'secret scanninge'