Skip to content

Commit 9564abf

Browse files
authored
[StepSecurity] Apply security best practices (microsoft#1379)
- Add https://github.com/gitleaks/gitleaks to pre commit config - Add missing top-level permissions and harden runner steps - Add Scorecard analysis StepSecurity analysis: step-security-bot@f79b588#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9
1 parent 7700ec4 commit 9564abf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+248
-110
lines changed

.github/workflows/CI.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ defaults:
1111
run:
1212
shell: pwsh
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
Test:
1619
runs-on: [ ubuntu-latest ]
1720
steps:
21+
- name: Harden Runner
22+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
23+
with:
24+
egress-policy: audit
25+
1826
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1927

2028
- name: Run Tests

.github/workflows/CleanupTempRepos.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ defaults:
1212
run:
1313
shell: pwsh
1414

15+
permissions:
16+
contents: read
17+
1518
jobs:
1619
Check:
1720
runs-on: [ ubuntu-latest ]
1821
outputs:
1922
githubOwner: ${{ steps.check.outputs.githubOwner }}
2023
steps:
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
26+
with:
27+
egress-policy: audit
28+
2129
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2230

2331
- name: Check secrets

.github/workflows/Deploy.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ jobs:
5252
createRelease: ${{ steps.CreateInputs.outputs.createRelease }}
5353
defaultBcContainerHelperVersion: ${{ steps.CreateInputs.outputs.defaultBcContainerHelperVersion }}
5454
steps:
55+
- name: Harden Runner
56+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
57+
with:
58+
egress-policy: audit
59+
5560
- name: Create inputs
5661
id: CreateInputs
5762
run: |
@@ -72,6 +77,11 @@ jobs:
7277
runs-on: [ ubuntu-latest ]
7378
needs: [ Inputs ]
7479
steps:
80+
- name: Harden Runner
81+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
82+
with:
83+
egress-policy: audit
84+
7585
- name: Check successful end 2 end tests have run
7686
if: github.repository_owner == 'microsoft' && needs.Inputs.outputs.requireEndToEndTests == 'true'
7787
env:
@@ -104,6 +114,11 @@ jobs:
104114
permissions:
105115
contents: write
106116
steps:
117+
- name: Harden Runner
118+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
119+
with:
120+
egress-policy: audit
121+
107122
- name: Validate Deployment
108123
if: github.repository_owner == 'microsoft'
109124
env:

.github/workflows/E2E.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ defaults:
4141
run:
4242
shell: pwsh
4343

44+
permissions:
45+
contents: read
46+
4447
jobs:
4548
Check:
4649
runs-on: [ ubuntu-latest ]
4750
outputs:
4851
maxParallel: ${{ steps.check.outputs.maxParallel }}
4952
githubOwner: ${{ steps.check.outputs.githubOwner }}
5053
steps:
54+
- name: Harden Runner
55+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
56+
with:
57+
egress-policy: audit
58+
5159
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5260

5361
- name: Check secrets
@@ -92,6 +100,11 @@ jobs:
92100
perTenantExtensionRepo: ${{ steps.setup.outputs.perTenantExtensionRepo }}
93101
appSourceAppRepo: ${{ steps.setup.outputs.appSourceAppRepo }}
94102
steps:
103+
- name: Harden Runner
104+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
105+
with:
106+
egress-policy: audit
107+
95108
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96109
with:
97110
ref: ${{ github.event.inputs.ref }}
@@ -111,6 +124,11 @@ jobs:
111124
releases: ${{ steps.Analyze.outputs.releases }}
112125
scenarios: ${{ steps.Analyze.outputs.scenarios }}
113126
steps:
127+
- name: Harden Runner
128+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
129+
with:
130+
egress-policy: audit
131+
114132
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
115133
with:
116134
ref: ${{ github.event.inputs.ref }}
@@ -187,6 +205,11 @@ jobs:
187205
if: github.event.inputs.runScenarios == 'true'
188206
strategy: ${{ fromJson(needs.Analyze.outputs.scenarios) }}
189207
steps:
208+
- name: Harden Runner
209+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
210+
with:
211+
egress-policy: audit
212+
190213
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
191214
with:
192215
ref: ${{ github.event.inputs.ref }}
@@ -218,6 +241,11 @@ jobs:
218241
if: github.event.inputs.runScenarios == 'true'
219242
strategy: ${{ fromJson(needs.Analyze.outputs.scenarios) }}
220243
steps:
244+
- name: Harden Runner
245+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
246+
with:
247+
egress-policy: audit
248+
221249
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
222250
with:
223251
ref: ${{ github.event.inputs.ref }}
@@ -249,6 +277,11 @@ jobs:
249277
if: github.event.inputs.runTestMatrix == 'true'
250278
strategy: ${{ fromJson(needs.Analyze.outputs.publictestruns) }}
251279
steps:
280+
- name: Harden Runner
281+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
282+
with:
283+
egress-policy: audit
284+
252285
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
253286
with:
254287
ref: ${{ github.event.inputs.ref }}
@@ -292,6 +325,11 @@ jobs:
292325
if: github.event.inputs.runTestMatrix == 'true' && github.event.inputs.includePrivateRepos == 'true'
293326
strategy: ${{ fromJson(needs.Analyze.outputs.privatetestruns) }}
294327
steps:
328+
- name: Harden Runner
329+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
330+
with:
331+
egress-policy: audit
332+
295333
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
296334
with:
297335
ref: ${{ github.event.inputs.ref }}
@@ -336,6 +374,11 @@ jobs:
336374
if: github.event.inputs.runUpgradeTests == 'true'
337375
strategy: ${{ fromJson(needs.Analyze.outputs.releases) }}
338376
steps:
377+
- name: Harden Runner
378+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
379+
with:
380+
egress-policy: audit
381+
339382
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
340383
with:
341384
ref: ${{ github.event.inputs.ref }}
@@ -376,6 +419,11 @@ jobs:
376419
needs: [ Check, SetupRepositories, TestAlGoPublic, TestAlGoPrivate, TestAlGoUpgrade, ScenariosOnWindows, ScenariosOnLinux ]
377420
if: always() && (!Cancelled()) && (needs.SetupRepositories.result == 'Success') && (needs.TestAlGoPublic.result == 'Success' || needs.TestAlGoPublic.result == 'Skipped') && (needs.TestAlGoPrivate.result == 'Success' || needs.TestAlGoPrivate.result == 'Skipped') && (needs.TestAlGoUpgrade.result == 'Success' || needs.TestAlGoUpgrade.result == 'Skipped') && (needs.Scenario.result == 'Success' || needs.Scenario.result == 'Skipped')
378421
steps:
422+
- name: Harden Runner
423+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
424+
with:
425+
egress-policy: audit
426+
379427
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
380428
with:
381429
ref: ${{ github.event.inputs.ref }}

.github/workflows/powershell.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
name: PSScriptAnalyzer
2020
runs-on: ubuntu-latest
2121
steps:
22+
- name: Harden Runner
23+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
24+
with:
25+
egress-policy: audit
26+
2227
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2328

2429
- name: Run PSScriptAnalyzer

.github/workflows/pre-commit.yml

+8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
pre-commit:
1114
runs-on: windows-latest
1215
steps:
16+
- name: Harden Runner
17+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
18+
with:
19+
egress-policy: audit
20+
1321
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1422
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
1523
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Scorecard Analysis
2+
on:
3+
branch_protection_rule:
4+
schedule:
5+
- cron: "0 8 * * 4" # Weekly on Thursday at 08:00 UTC
6+
push:
7+
branches: ["main"]
8+
9+
permissions: read-all
10+
11+
jobs:
12+
analysis:
13+
name: Scorecard analysis
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write # Needed to upload the results to code-scanning dashboard.
17+
id-token: write # Needed to publish results and get a badge (see publish_results below).
18+
19+
steps:
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
22+
with:
23+
egress-policy: audit
24+
25+
- name: "Checkout code"
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
with:
28+
persist-credentials: false
29+
30+
- name: "Run analysis"
31+
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
32+
with:
33+
results_file: results.sarif
34+
results_format: sarif
35+
publish_results: true
36+
37+
# Upload the results to GitHub's code scanning dashboard.
38+
- name: "Upload to code-scanning"
39+
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
40+
with:
41+
sarif_file: results.sarif

.pre-commit-config.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
repos:
55
- repo: https://github.com/executablebooks/mdformat
6-
rev: 0.7.17
6+
rev: 0.7.21
77
hooks:
88
- id: mdformat
99
args: [--end-of-line=keep]
1010

1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.5.0
12+
rev: v5.0.0
1313
hooks:
1414
- id: check-added-large-files
1515
- id: check-case-conflict
@@ -22,3 +22,8 @@ repos:
2222
- id: trailing-whitespace
2323
- id: mixed-line-ending
2424
- id: sort-simple-yaml
25+
26+
- repo: https://github.com/gitleaks/gitleaks
27+
rev: v8.16.3
28+
hooks:
29+
- id: gitleaks

Actions/ReadSecrets/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ none
3434
| Name | Description |
3535
| :-- | :-- |
3636
| Secrets | A compressed json construct with all requested secrets base64 encoded. Secrets preceded by an asterisk (\*) are encrypted before base64 encoding. The secret value + the base64 value of the secret value are masked in the log |
37-
| TokenForPush | The token to use when workflows are pushing changes (either directly, or via pull requests). This is either the GITHUB_TOKEN or the GhTokenWorkflow secret (based on the env variable useGhTokenWorkflowForPush) |
37+
| TokenForPush | The token to use when workflows are pushing changes (either directly, or via pull requests). This is either the GITHUB_TOKEN or the GhTokenWorkflow secret (based on the env variable useGhTokenWorkflowForPush) |

Actions/ReadSettings/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ none
2424
| :-- | :-- |
2525
| Settings | A compressed JSON structure with ALL AL-Go settings, independent of the get parameter. If project was not specified, this will only include repository settings. |
2626

27-
> \[!NOTE\]
27+
> [!NOTE]
2828
> This method creates individual environment variables for every setting specified in the get parameter.
2929
3030
### OUTPUT variables

Actions/RunPipeline/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Run pipeline in AL-Go repository
2020
| artifact | | ArtifactUrl to use for the build | settings.artifact |
2121
| project | | Project name if the repository is setup for multiple projects | . |
2222
| buildMode | | Specifies a mode to use for the build steps | Default |
23-
| installAppsJson | | A JSON-formatted list of apps to install | \[\] |
24-
| installTestAppsJson | | A JSON-formatted list of test apps to install | \[\] |
23+
| installAppsJson | | A JSON-formatted list of apps to install | [] |
24+
| installTestAppsJson | | A JSON-formatted list of test apps to install | [] |
2525

2626
## OUTPUT
2727

Actions/SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you believe you have found a security vulnerability in any Microsoft-owned re
1212

1313
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
1414

15-
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
15+
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
1616

1717
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
1818

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Try out the [AL-Go workshop](https://aka.ms/algoworkshop) for an in-depth worksh
4343
A. [Migrate a repository from Azure DevOps to AL-Go for GitHub without history](Scenarios/MigrateFromAzureDevOpsWithoutHistory.md)<br />
4444
B. [Migrate a repository from Azure DevOps to AL-Go for GitHub with history](Scenarios/MigrateFromAzureDevOpsWithHistory.md)
4545

46-
> \[!NOTE\]
46+
> [!NOTE]
4747
> Please refer to [this description](Scenarios/settings.md) to learn about the settings file and how you can modify default behaviors.
4848
4949
# This project
@@ -58,7 +58,7 @@ This project in the main source repository for AL-Go for GitHub. This project is
5858

5959
Please read [this document](Scenarios/Contribute.md) to understand how to contribute to AL-Go for GitHub.
6060

61-
This project welcomes contributions and suggestions. Most contributions require you to agree to a
61+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
6262
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
6363
the rights to use your contribution. For details, visit [https://cla.opensource.microsoft.com](https://cla.opensource.microsoft.com).
6464

0 commit comments

Comments
 (0)