Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/trusted GitHub #20

Merged
merged 36 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
032aa27
added trusted github account check
raianand Apr 1, 2024
3bdf3f0
added trusted account check in interceptor
raianand Apr 2, 2024
ccfd63a
instrumenting bolt service with trusted accounts
raianand Apr 2, 2024
28cd7c6
updated summary to reflect untrusted github accounts
raianand Apr 2, 2024
26ce0a9
added github trusted account input variable
raianand Apr 2, 2024
9ec900f
fixed summary and added dist
raianand Apr 2, 2024
feb92c6
fixed pylint issues
raianand Apr 2, 2024
81580b2
added pre release flag
raianand Apr 2, 2024
07eb28d
input yaml parsing for trusted github accounts
raianand Apr 2, 2024
49d4f65
fixed issue
raianand Apr 2, 2024
fc6f96f
fixed summary issue
raianand Apr 2, 2024
58898c7
added release version check
raianand Apr 2, 2024
da35d1f
removed deprecated set-output
raianand Apr 2, 2024
899b1bb
summary beautification
raianand Apr 2, 2024
9f2d8c9
summary fixes
raianand Apr 2, 2024
38db3db
summary fixes
raianand Apr 2, 2024
dfb2c1b
trying collapsible summary tables
raianand Apr 2, 2024
8d93a24
increased wait after bolt start
raianand Apr 2, 2024
ad729b7
better summary
raianand Apr 2, 2024
bd9399f
known/unknown destinations
raianand Apr 2, 2024
2e44e6e
summary duplicate fix
raianand Apr 2, 2024
83e967e
updated README
raianand Apr 2, 2024
17a158e
fixed Koala Link
raianand Apr 2, 2024
9a4a264
trusted github accounts config in summary
raianand Apr 2, 2024
cc7ed4b
separators in summary
raianand Apr 2, 2024
ddb41e3
fixed gh accounts table
raianand Apr 2, 2024
05f1482
fixed shell-check issue
raianand Apr 2, 2024
ef337a0
removed light logo for marketplace compatibility
raianand Apr 2, 2024
741ef06
pinned actions
raianand Apr 2, 2024
2edd389
added checks for linux platform
raianand Apr 2, 2024
7ab0132
platform related failure message
raianand Apr 2, 2024
544e0cc
fix tests
raianand Apr 2, 2024
b5013e0
release version check fix
raianand Apr 2, 2024
7b57230
added example workflow
raianand Apr 2, 2024
cdaa2e5
added ref of examples in readme
raianand Apr 2, 2024
e67091a
version bump 1.3.0
raianand Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
6 changes: 3 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # actions/checkout@v4 | 1567,v4.1.1

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # actions/setup-node@v4 | v4.0.2
with:
node-version-file: .node-version
cache: npm
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # actions/upload-artifact@v4 | v4.3.1
with:
name: dist
path: dist/
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # actions/checkout@v4 | 1567,v4.1.1

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # actions/setup-node@v4 | v4.0.2
with:
node-version-file: .node-version
cache: npm
Expand Down Expand Up @@ -49,4 +49,4 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # actions/checkout@v4 | 1567,v4.1.1
6 changes: 3 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # actions/checkout@v4 | 1567,v4.1.1
with:
fetch-depth: 0

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # actions/setup-node@v4 | v4.0.2
with:
node-version-file: .node-version
cache: npm
Expand All @@ -36,7 +36,7 @@ jobs:

- name: Lint Codebase
id: super-linter
uses: super-linter/super-linter/slim@v6
uses: super-linter/super-linter/slim@e0fc164bba85f4b58c6cd17ba1dfd435d01e8a06 # super-linter/super-linter/slim@v6
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ jobs:
arch: x86_64
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # actions/checkout@v4 | 1567,v4.1.1
- name: Get release version
id: releaseVersion
run: echo "releaseVersion=\"$(awk -F\' '/const releaseVersion/ { print $2 }' src/version.js)\"" >> "$GITHUB_ENV"
- name: Check if releaseVersion is same as tag
run: |
if [ "${{ env.tag }}" != "${{ env.releaseVersion }}" ]; then
echo "releaseVersion does not match the tag"
exit 1
fi
- name: Fetch MITM-Proxy
run: |
mkdir -p mitmproxy
Expand All @@ -31,11 +40,11 @@ jobs:
rm -rf mitmproxy bolt
rm mitmproxy-10.2.2-linux-x86_64.tar.gz
- name: Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # softprops/action-gh-release@v2
with:
files: bolt-${{ env.tag }}-${{ env.os }}-${{ env.arch }}.tar.gz
tag_name: ${{ env.tag }}
name: ${{ env.tag }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}

prerelease: ${{ endsWith(env.tag, 'rc') }}
92 changes: 70 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
![Bolt](assets/imgs/bolt-header-light.png#gh-light-mode-only)
![Bolt](assets/imgs/bolt-header-dark.png#gh-dark-mode-only)
![Bolt](assets/imgs/bolt-header-dark.png)
## Secure GitHub actions with 1 line of code
Add this step to jobs in your GitHub workflow file(s) to secure your runner:
```yaml
Expand Down Expand Up @@ -42,6 +41,8 @@ You can configuree the Bolt action using inputs. Here is an example of how to co
mode: 'audit'
default_policy: 'block-all'
allow_http: 'false'
trusted_github_accounts: |
- 'akto-api-security'
egress_rules: |
- name: 'Allow GitHub subs'
destination: '*.github.com'
Expand All @@ -52,6 +53,7 @@ You can configuree the Bolt action using inputs. Here is an example of how to co
| `mode` | Configure the mode of operation for the Bolt gateway. It can be `audit` or `active`. Default: `audit` |
| `default_policy` | It can be either `block-all` or `allow-all`. Default: `block-all` |
| `allow_http` | Whether to allow non-secure HTTP requests or not. Default: `false`
| `trusted_github_accounts` | A list of trusted GitHub accounts. Default: `[]`. The account in which workflow is running will always be trusted.
| `egress_rules` | A list of custom egress rules to be applied. Default: `[]`.

## Custom Egress Policy
Expand Down Expand Up @@ -91,23 +93,69 @@ It is an ordered list of rules. The first rule that matches the destination will
## Report
Once the job is over, bolt will add a egress traffic report to the job summary. The report will show the egress traffic and the rules that were applied. A sample report is shown below.

### Egress Report - powered by Bolt
#### Bolt Configuration

|Option | Value |
|---|---|
| Mode | audit |
| Default Policy | block-all |
| Allow HTTP | false |

#### Custom Egress Rules
```yaml
- name: 'Allow ifconfig.me'
action: 'allow'
destinatiom: 'ifconfig.me'
```
#### Egress Traffic
> [!NOTE]
>
> Running in Audit mode. Unverified destinations will be blocked in Active mode.
<table><tr><th>Destination</th><th>Scheme</th><th>Rule</th><th>Action</th></tr><tr><td>github.com</td><td>https</td><td>Reqd by GitHub Action</td><td>✅</td></tr><tr><td>packages.microsoft.com</td><td>https</td><td>Default Policy - block-all</td><td>Unknown Destination</td></tr><tr><td>results-receiver.actions.githubusercontent.com</td><td>https</td><td>Reqd by GitHub Action</td><td>✅</td></tr><tr><td>ppa.launchpadcontent.net</td><td>https</td><td>Default Policy - block-all</td><td>Unknown Destination</td></tr><tr><td>esm.ubuntu.com</td><td>https</td><td>Default Policy - block-all</td><td>Unknown Destination</td></tr><tr><td>azure.archive.ubuntu.com</td><td>http</td><td>allow_http is False</td><td>Unknown Destination</td></tr><tr><td>www.google.com</td><td>https</td><td>Default Policy - block-all</td><td>Unknown Destination</td></tr><tr><td>ifconfig.me</td><td>https</td><td>Allow ifconfig.me</td><td>✅</td></tr><tr><td>pipelinesghubeus6.actions.githubusercontent.com</td><td>https</td><td>Reqd by GitHub Action</td><td>✅</td></tr></table>
<hr>

<h2>⚡ Egress Report - powered by Bolt</h2>

<details open>
<summary>
<h3>🛠️ Bolt Configuration</h3>

</summary>
<table><tr><td>Mode</td><td>audit</td></tr><tr><td>Allow HTTP</td><td>false</td></tr><tr><td>Default Policy</td><td>block-all</td></tr></table>

</details>

<details open>
<summary>
<h4>🔒 Trusted Github Accounts</h4>

</summary>
<table><tr><th>Github Account</th></tr><tr><td>akto-api-security</td></tr></table>

</details>
<blockquote>NOTE: The account in which workflow runs is always trusted.</blockquote>
<h3>📝 Egress rules</h3>
<pre lang="yaml"><code>- destination: google.com
action: block
name: Block Google
- destination: ifconfig.me
action: allow
name: Allow ifconfig.me</code></pre>
<h3>🚨 Requests to untrusted GitHub accounts found</h3>

> [!CAUTION]
> If you do not recognize these GitHub Accounts, you may want to investigate further. Add them to your trusted GitHub accounts if this is expected. See [Docs](https://github.com/koalalab-inc/bolt?tab=readme-ov-file#configure) for more information.

<details open>
<summary>
razorpay
</summary>
<ul>
<li>/orgs/razorpay/repos</li>
</ul>
</details>
<h3>Egress Traffic</h3>
<blockquote>NOTE: Running in Audit mode. Unknown/unverified destinations will be blocked in Active mode.</blockquote>

<details open>
<summary>
<h4>🚨 Unknown Destinations</h4>

</summary>
<table><tr><th>Destination</th><th>Scheme</th><th>Rule</th><th>Action</th></tr><tr><td>www.google.com</td><td>https</td><td>Default Policy - block-all</td><td>Unknown Destination</td></tr></table>

</details>

<details>
<summary>
<h4>✅ Known Destinations</h4>

</summary>
<table><tr><th>Destination</th><th>Scheme</th><th>Rule</th><th>Action</th></tr><tr><td>github.com</td><td>https</td><td>Reqd by Github Action</td><td>✅</td></tr><tr><td>pipelinesghubeus6.actions.githubusercontent.com</td><td>https</td><td>Reqd by Github Action</td><td>✅</td></tr><tr><td>results-receiver.actions.githubusercontent.com</td><td>https</td><td>Reqd by Github Action</td><td>✅</td></tr><tr><td>ifconfig.me</td><td>https</td><td>Allow ifconfig.me</td><td>✅</td></tr><tr><td>api.github.com</td><td>https</td><td>Reqd by Github Action</td><td>✅</td></tr></table>

</details>
<a href="https://www.koalalab.com">View detailed analysis of this run on Koalalab!</a>
<hr>

This report was generated using this workflow file: [bolt-sample.yml](examples/bolt.yml)
12 changes: 10 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ jest.mock('../src/main', () => ({
}))

describe('index', () => {
it('calls run when imported', async () => {
require('../src/index')
it('calls run when imported on linux', async () => {
const { init } = require('../src/index')
init('linux', 'x64')

expect(run).toHaveBeenCalled()
})

it('fails when imported on platform other than linux', async () => {
const { init } = require('../src/index')
init('darwin', 'x64')

expect(run).not.toHaveBeenCalled()
})
})
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: 'Default policy for egress traffic - allow-all or block-all'
required: false
default: 'block-all'
trusted_github_accounts:
description: 'Trusted Github accounts'
required: false
default: '[]'
egress_rules:
description: 'Egress rules'
required: false
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading