Skip to content

Commit f143045

Browse files
authored
Merge pull request #136 from github-community-projects/fix/security-hardening-uv-invocations
fix: tighten workflow permissions, add security hardening, and fix uv tool invocations
2 parents 315fd85 + 4da1a8f commit f143045

14 files changed

+273
-16
lines changed

.github/copilot-instructions.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copilot Instructions
2+
3+
This is a GitHub Action that measures InnerSource collaboration in a GitHub organization. It identifies cross-team contributions by analyzing pull requests and their authors against repository ownership, then generates a report as a GitHub issue or Markdown file.
4+
5+
## Code Standards
6+
7+
### Required Before Each Commit
8+
9+
- Run `make lint` before committing any changes to ensure proper code linting and formatting.
10+
11+
### Development Flow
12+
13+
- Lint: `make lint`
14+
- Test: `make test`
15+
16+
## Repository Structure
17+
18+
- `Makefile`: Contains commands for linting, testing, and other tasks
19+
- `pyproject.toml`: Python dependencies and project configuration
20+
- `README.md`: Project documentation and setup instructions
21+
- `test_*.py`: Python test files matching the naming convention for test discovery
22+
23+
## Key Guidelines
24+
25+
1. Follow Python best practices and idiomatic patterns
26+
2. Maintain existing code structure and organization
27+
3. Write unit tests for new functionality.
28+
4. Document changes to environment variables in the `README.md` file.

.github/workflows/codeql.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ["main"]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: ["main"]
20+
schedule:
21+
- cron: "0 0 * * 1"
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
analyze:
28+
name: Analyze
29+
runs-on: ubuntu-latest
30+
permissions:
31+
actions: read
32+
contents: read
33+
security-events: write
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
language: ["python"]
39+
# CodeQL supports [ $supported-codeql-languages ]
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41+
42+
steps:
43+
- name: Harden the runner (Audit all outbound calls)
44+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
45+
with:
46+
egress-policy: audit
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
50+
with:
51+
persist-credentials: false
52+
53+
# Initializes the CodeQL tools for scanning.
54+
- name: Initialize CodeQL
55+
uses: github/codeql-action/init@820e3160e279568db735cee8ed8f8e77a6da7818 # v3.32.6
56+
with:
57+
languages: ${{ matrix.language }}
58+
# If you wish to specify custom queries, you can do so here or in a config file.
59+
# By default, queries listed here will override any specified in a config file.
60+
# Prefix the list here with "+" to use these queries and those in the config file.
61+
62+
# If the Autobuild fails above, remove it and uncomment the following three lines.
63+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
64+
65+
# - run: |
66+
# echo "Run, Build Application using script"
67+
# ./location_of_script_within_repo/buildscript.sh
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@820e3160e279568db735cee8ed8f8e77a6da7818 # v3.32.6
71+
with:
72+
category: "/language:${{matrix.language}}"

.github/workflows/contributor_report.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ on:
55
- cron: "3 2 1 * *"
66

77
permissions:
8-
issues: write
8+
contents: read
99

1010
jobs:
1111
contributor_report:
1212
name: contributor report
1313
runs-on: ubuntu-latest
14+
permissions:
15+
issues: write
1416

1517
steps:
18+
- name: Harden the runner (Audit all outbound calls)
19+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
20+
with:
21+
egress-policy: audit
22+
1623
- name: Get dates for last month
1724
shell: bash
1825
run: |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
# Set the permissions to the lowest permissions possible needed for your steps.
15+
# Copilot will be given its own token for its operations.
16+
permissions:
17+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
18+
contents: read
19+
20+
jobs:
21+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
22+
copilot-setup-steps:
23+
runs-on: ubuntu-latest
24+
25+
# You can define any steps you want, and they will run before the agent starts.
26+
# If you do not check out your code, Copilot will do this for you.
27+
steps:
28+
- name: Harden the runner (Audit all outbound calls)
29+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
30+
with:
31+
egress-policy: audit
32+
33+
- name: Checkout code
34+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
with:
36+
persist-credentials: false
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
40+
with:
41+
version: "0.10.9"
42+
enable-cache: true
43+
44+
- name: Set up Python
45+
run: uv python install 3.14
46+
47+
- name: Install dependencies
48+
run: uv sync --frozen --python 3.14
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dependency Review Action
2+
#
3+
# This Action will scan dependency manifest files that change as part of a Pull Request,
4+
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
5+
# Once installed, if the workflow run is marked as required,
6+
# PRs introducing known-vulnerable packages will be blocked from merging.
7+
#
8+
# Source repository: https://github.com/actions/dependency-review-action
9+
name: "Dependency Review"
10+
on: [pull_request]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
dependency-review:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Harden the runner (Audit all outbound calls)
20+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
21+
with:
22+
egress-policy: audit
23+
24+
- name: "Checkout Repository"
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
with:
27+
persist-credentials: false
28+
- name: "Dependency Review"
29+
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0

.github/workflows/docker-image.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17+
- name: Harden the runner (Audit all outbound calls)
18+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
19+
with:
20+
egress-policy: audit
21+
1722
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1823
with:
1924
persist-credentials: false

.github/workflows/linter.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
packages: read
2222
statuses: write
2323
steps:
24+
- name: Harden the runner (Audit all outbound calls)
25+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
26+
with:
27+
egress-policy: audit
28+
2429
- name: Checkout Code
2530
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2631
with:

.github/workflows/mark-ready-when-ready.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ on:
55
types: [opened, edited, labeled, unlabeled, synchronize]
66

77
permissions:
8-
checks: read
9-
contents: write
10-
pull-requests: write
11-
statuses: read
8+
contents: read
129

1310
concurrency:
1411
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
@@ -18,10 +15,20 @@ jobs:
1815
mark-ready:
1916
name: Mark as ready after successful checks
2017
runs-on: ubuntu-latest
18+
permissions:
19+
checks: read
20+
contents: write
21+
pull-requests: write
22+
statuses: read
2123
if: |
2224
contains(github.event.pull_request.labels.*.name, 'Mark Ready When Ready') &&
2325
github.event.pull_request.draft == true
2426
steps:
27+
- name: Harden the runner (Audit all outbound calls)
28+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
29+
with:
30+
egress-policy: audit
31+
2532
- name: Mark ready when ready
2633
uses: kenyonj/mark-ready-when-ready@33b13c51ba23786efb933701ef253352baf05bdd # main (contents:write fix)
2734
with:

.github/workflows/python-package.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
python-version: [3.11, 3.12, 3.13, 3.14]
2626

2727
steps:
28+
- name: Harden the runner (Audit all outbound calls)
29+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
30+
with:
31+
egress-policy: audit
32+
2833
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2934
with:
3035
persist-credentials: false

.github/workflows/scorecard.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@ on:
1313
push:
1414
branches: [main]
1515

16-
permissions: read-all
16+
permissions:
17+
contents: read
1718

1819
jobs:
1920
analysis:
2021
name: Merge to Main Scorecard analysis
2122
runs-on: ubuntu-latest
2223
permissions:
24+
contents: read
2325
security-events: write
2426
id-token: write
2527

2628
steps:
29+
- name: Harden the runner (Audit all outbound calls)
30+
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
31+
with:
32+
egress-policy: audit
33+
2734
- name: "Checkout code"
2835
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2936
with:

0 commit comments

Comments
 (0)