Skip to content

Commit eacfd84

Browse files
[StepSecurity] Apply security best practices
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
1 parent a47cbd9 commit eacfd84

6 files changed

Lines changed: 172 additions & 9 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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@v2
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0

‎.github/workflows/scorecards.yml‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '20 7 * * 2'
14+
push:
15+
branches: ["main"]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
permissions:
25+
# Needed to upload the results to code-scanning dashboard.
26+
security-events: write
27+
# Needed to publish results and get a badge (see publish_results below).
28+
id-token: write
29+
contents: read
30+
actions: read
31+
# To allow GraphQL ListCommits to work
32+
issues: read
33+
pull-requests: read
34+
# To detect SAST tools
35+
checks: read
36+
37+
steps:
38+
- name: Harden the runner (Audit all outbound calls)
39+
uses: step-security/harden-runner@v2
40+
with:
41+
egress-policy: audit
42+
43+
- name: "Checkout code"
44+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
45+
with:
46+
persist-credentials: false
47+
48+
- name: "Run analysis"
49+
uses: ossf/scorecard-action@55891bbd73f2425e97637d96e306fc9d491d0b21 # v2.4.4
50+
with:
51+
results_file: results.sarif
52+
results_format: sarif
53+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
54+
# - you want to enable the Branch-Protection check on a *public* repository, or
55+
# - you are installing Scorecards on a *private* repository
56+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
57+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
58+
59+
# Public repositories:
60+
# - Publish results to OpenSSF REST API for easy access by consumers
61+
# - Allows the repository to include the Scorecard badge.
62+
# - See https://github.com/ossf/scorecard-action#publishing-results.
63+
# For private repositories:
64+
# - `publish_results` will always be set to `false`, regardless
65+
# of the value entered here.
66+
publish_results: true
67+
68+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
69+
# format to the repository Actions tab.
70+
- name: "Upload artifact"
71+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
72+
with:
73+
name: SARIF file
74+
path: results.sarif
75+
retention-days: 5
76+
77+
# Upload the results to GitHub's code scanning dashboard.
78+
- name: "Upload to code-scanning"
79+
uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
80+
with:
81+
sarif_file: results.sarif

‎.github/workflows/workflow.yaml‎

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18+
- name: Harden the runner (Audit all outbound calls)
19+
uses: step-security/harden-runner@v2
20+
with:
21+
egress-policy: audit
22+
1823
- name: Clone repository
19-
uses: actions/checkout@v7
24+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2025
- name: Run shellcheck
2126
uses: step-security/action-shellcheck@v2
2227

@@ -34,8 +39,13 @@ jobs:
3439
channel: main
3540

3641
steps:
42+
- name: Harden the runner (Audit all outbound calls)
43+
uses: step-security/harden-runner@v2
44+
with:
45+
egress-policy: audit
46+
3747
- name: Clone repository
38-
uses: actions/checkout@v7
48+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3949
- id: flutter-action
4050
uses: ./
4151
with:
@@ -74,8 +84,13 @@ jobs:
7484
operating-system: ${{ github.actor == 'dependabot[bot]' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "windows-latest", "macos-latest"]') }}
7585

7686
steps:
87+
- name: Harden the runner (Audit all outbound calls)
88+
uses: step-security/harden-runner@v2
89+
with:
90+
egress-policy: audit
91+
7792
- name: Clone repository
78-
uses: actions/checkout@v7
93+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7994
- uses: ./
8095
with:
8196
channel: stable
@@ -94,8 +109,13 @@ jobs:
94109
operating-system: ${{ github.actor == 'dependabot[bot]' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest"]') }}
95110

96111
steps:
112+
- name: Harden the runner (Audit all outbound calls)
113+
uses: step-security/harden-runner@v2
114+
with:
115+
egress-policy: audit
116+
97117
- name: Clone repository
98-
uses: actions/checkout@v7
118+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
99119
- uses: ./
100120
with:
101121
channel: stable
@@ -115,8 +135,13 @@ jobs:
115135
operating-system: ${{ github.actor == 'dependabot[bot]' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest"]') }}
116136

117137
steps:
138+
- name: Harden the runner (Audit all outbound calls)
139+
uses: step-security/harden-runner@v2
140+
with:
141+
egress-policy: audit
142+
118143
- name: Clone repository
119-
uses: actions/checkout@v7
144+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
120145
- id: flutter-action
121146
uses: ./
122147
with:
@@ -143,8 +168,13 @@ jobs:
143168
# Test mode uses hardcoded Flutter release manifests from test/ directory.
144169

145170
steps:
171+
- name: Harden the runner (Audit all outbound calls)
172+
uses: step-security/harden-runner@v2
173+
with:
174+
egress-policy: audit
175+
146176
- name: Clone repository
147-
uses: actions/checkout@v7
177+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
148178
- run: ./setup.sh -t -p -f test/pubspec.yaml | grep '3.3.10'
149179
shell: bash
150180
- run: ./setup.sh -t -p | grep 'stable'
@@ -241,8 +271,13 @@ jobs:
241271
# Test mode uses hardcoded Flutter release manifests from test/ directory.
242272

243273
steps:
274+
- name: Harden the runner (Audit all outbound calls)
275+
uses: step-security/harden-runner@v2
276+
with:
277+
egress-policy: audit
278+
244279
- name: Clone repository
245-
uses: actions/checkout@v7
280+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
246281
- run: ./setup.sh -t -p -f test/pubspec.yaml | grep '3.3.10'
247282
shell: bash
248283
- run: ./setup.sh -t -p | grep 'stable'

‎.pre-commit-config.yaml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/gitleaks/gitleaks
3+
rev: v8.30.1
4+
hooks:
5+
- id: gitleaks
6+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
7+
rev: 3.0.0
8+
hooks:
9+
- id: shellcheck
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v6.0.0
12+
hooks:
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace

‎action.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ runs:
174174
175175
- name: Cache Flutter
176176
id: cache-flutter
177-
uses: actions/cache@v5
177+
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
178178
if: ${{ inputs.cache == 'true' }}
179179
with:
180180
path: ${{ steps.flutter-action.outputs.CACHE-PATH }}
181181
key: ${{ steps.flutter-action.outputs.CACHE-KEY }}
182182

183183
- name: Cache pub dependencies
184-
uses: actions/cache@v5
184+
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
185185
id: cache-pub
186186
if: ${{ (inputs.pub-cache == '' && inputs.cache == 'true') || inputs.pub-cache == 'true' }}
187187
with:

0 commit comments

Comments
 (0)