Skip to content

Commit 1c533d7

Browse files
committed
Initial commit
0 parents  commit 1c533d7

22 files changed

+24639
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.vscode
3+
.vs

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2023 GitHub, Inc. and contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# GitHub token permissions usage Monitor and Advisor actions (PUBLIC BETA)
2+
3+
Applying the least privilege permissions to a GitHub Actions workflow is a best security practice, but can be challenging as it may break existing workflows.
4+
5+
The Monitor action, when added to a workflow, tracks the usage of the temporary GitHub repository token and gives recommendations on the minimum permissions required to run the workflow based on the actual detected workflow activity. Every workflow run generates a summary report with the recommendations. Since some steps or jobs may be skipped based on various conditions, the Advisor action can aggregate and summarize the recommendations from multiple workflow runs.
6+
7+
![Workflow run summary with permissions recommendations for every job](res/summary.png "Minimal required permissions")
8+
9+
The typical scenario is to include the Monitor action in every job of the workflow that doesn't specify permissions explicitly, collect the recommendations from several workflow runs, apply the recommended minimal permissions, and then remove the Monitor action.
10+
11+
## Usage
12+
13+
[See the Monitor action](monitor)
14+
15+
[See the Advisor action](advisor)

SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Security Policy
2+
3+
Please send security findings to securitylab at github com.

advisor/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# GitHub token permissions Advisor action (PUBLIC BETA)
2+
3+
## Usage
4+
5+
The index.js script can be invoked as:
6+
7+
* GitHub action.
8+
9+
See [workflow.yml](workflow.yml) for an example of how to use the Advisor action. Copy the workflow to your repository and manually dispatch the workflow from the Actions tab to generate the aggregated report from the last `n` runs.
10+
11+
![Run workflow form with input fields](../res/dispatch.png "Run workflow")
12+
13+
* Command line tool.
14+
15+
Download the [index.js](index.js) script and run it as:\
16+
17+
```bash
18+
node index.js <workflow_name.yml> <number_of_the_last_runs> <github_owner> <repo_name> <branch_name>
19+
```
20+
21+
An environment variable `GITHUB_TOKEN` must be set to your [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with `repo` scope granted for the repository you want to analyze.

advisor/action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'GitHub Actions Permissions Advisor'
2+
description: 'An action to aggregate results from Permissions Monitor from the previous runs and advise the minimal permissions required for a GitHub Action'
3+
inputs:
4+
token:
5+
description: 'The repository token to read previous runs'
6+
required: false
7+
default: ${{ github.token }}
8+
name:
9+
description: 'The name of the workflow file to analyze'
10+
required: true
11+
type: string
12+
count:
13+
description: 'How many last runs to analyze'
14+
required: false
15+
type: number
16+
default: 10
17+
18+
runs:
19+
using: 'node16'
20+
main: 'dist/index.js'

0 commit comments

Comments
 (0)