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

[StepSecurity] Apply security best practices #1606

Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
400cc49
[StepSecurity] Apply security best practices
step-security-bot Jan 18, 2024
3ba08da
Update .pre-commit-config.yaml
Zeitsperre Jan 18, 2024
1b1ada7
convert testdata_version to trigger on pull_request_target
Zeitsperre Jan 18, 2024
41f34fb
configure pylint with toml support, address some small errors
Zeitsperre Jan 18, 2024
47609cb
update target config
Zeitsperre Jan 18, 2024
74f63e9
ignore .pylintrc.toml
Zeitsperre Jan 18, 2024
91381b2
fix logging
Zeitsperre Jan 18, 2024
529f656
undo regression
Zeitsperre Jan 18, 2024
9d1cd10
more tuning
Zeitsperre Jan 18, 2024
195ea42
reconfigure pylint for pre-commit, adjust formatting and exceptions
Zeitsperre Jan 18, 2024
b039e8a
pylint adjustments
Zeitsperre Jan 19, 2024
e593786
disable pylint checks that are incompatible with mapblocks
Zeitsperre Jan 19, 2024
a8e8bfa
update dependabot.yml configuration, add job concerning workflow chan…
Zeitsperre Jan 19, 2024
1d5e7e9
security-related changes
Zeitsperre Jan 19, 2024
10291a8
rename some workflows for consistency
Zeitsperre Jan 19, 2024
80c1742
run on pull_request_target
Zeitsperre Jan 19, 2024
6a80c00
deactivate actions-versions-updater.yml (handled by dependabot now), …
Zeitsperre Jan 19, 2024
a63f9a2
small adjustments
Zeitsperre Jan 19, 2024
ca2ca17
remove some pylint warnings, mark map_groups as modifying call signat…
Zeitsperre Jan 19, 2024
d7a50dc
remove pylint statements
Zeitsperre Jan 19, 2024
90f78fb
treat xclim.indicators as a module with run-time submodules
Zeitsperre Jan 19, 2024
9320f63
re-add pragma: no cover
Zeitsperre Jan 19, 2024
380210b
noqa adjustment
Zeitsperre Jan 19, 2024
65fc23c
update CHANGES.rst
Zeitsperre Jan 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
github.com:443

- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: ${{ secrets.ACTIONS_VERSION_UPDATER_TOKEN }}
persist-credentials: true

- name: Run GitHub Actions Version Updater
uses: saadmk11/[email protected]
uses: saadmk11/github-actions-version-updater@64be81ba69383f81f2be476703ea6570c4c8686e # v0.8.1
with:
token: ${{ secrets.ACTIONS_VERSION_UPDATER_TOKEN }}
committer_email: 'bumpversion[bot]@ouranos.ca'
Expand Down
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
time: '12:00'
open-pull-requests-limit: 5

- package-ecosystem: pip
directory: /
schedule:
interval: daily
time: '12:00'
open-pull-requests-limit: 5
4 changes: 2 additions & 2 deletions .github/workflows/add-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types:
- opened

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -24,7 +24,7 @@ jobs:
allowed-endpoints: >
api.github.com:443

- uses: actions/[email protected]
- uses: actions/add-to-project@31b3f3ccdc584546fc445612dec3f38ff5edb41c # v0.5.0
with:
project-url: https://github.com/orgs/Ouranosinc/projects/6
github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- tox.ini
- xclim/__init__.py

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -43,10 +43,10 @@ jobs:
files.pythonhosted.org:443
github.com:443
pypi.org:443
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- uses: actions/[email protected]
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.x"
- name: Config Commit Bot
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cache-cleaner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types:
- closed

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -23,7 +23,7 @@ jobs:
objects.githubusercontent.com:443

- name: Check out code
uses: actions/[email protected]
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Cleanup
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
pypi.org:443
uploads.github.com:443
- name: Checkout repository
uses: actions/[email protected]
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@1245696032ecf7d39f87d54daa406e22ddf769a8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
github.com:443

- name: 'Checkout Repository'
uses: actions/[email protected]
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: 'Dependency Review'
uses: actions/dependency-review-action@c74b580d73376b7750d3d2a50bfb8adc2c937507
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types:
- opened

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -24,7 +24,7 @@ jobs:
allowed-endpoints: >
api.github.com:443

- uses: actions/[email protected]
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
// Get a list of all issues created by the PR opener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
api.github.com:443

- name: Label Approved
uses: actions/[email protected]
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.issues.addLabels({
Expand All @@ -58,20 +58,23 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
- name: Find comment
uses: peter-evans/[email protected]
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This Pull Request is coming from a fork and must be manually tagged `approved` in order to perform additional testing
body-includes: This Pull Request is coming from a fork and must be manually tagged `approved` in order to perform additional testing.
- name: Create comment
if: |
(steps.fc.outputs.comment-id == '') &&
(!contains(github.event.pull_request.labels.*.name, 'approved')) &&
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
uses: peter-evans/[email protected]
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -82,7 +85,7 @@ jobs:
- name: Update comment
if: |
contains(github.event.pull_request.labels.*.name, 'approved')
uses: peter-evans/[email protected]
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
# https://github.com/actions/labeler/blob/master/README.md

name: Labeler
on: [pull_request_target]
on:
# Note: potential security risk from this action using pull_request_target.
# Do not add actions in here which need a checkout of the repo, and do not use any caching in here.
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
pull_request_target:
types:
- opened
- reopened
- synchronize

permissions:
contents: read
Expand All @@ -30,6 +35,7 @@ jobs:
egress-policy: block
allowed-endpoints: >
api.github.com:443
- uses: actions/[email protected]

- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ jobs:
files.pythonhosted.org:443
github.com:443
pypi.org:443
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install pylint and tox
run: pip install pylint tox~=4.0
- name: Run pylint
run: |
python -m pylint --rcfile=pylintrc --disable=import-error --exit-zero xclim
python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero xclim
- name: Run linting suite
run: |
python -m tox -e lint
Expand All @@ -88,9 +88,9 @@ jobs:
github.com:443
pypi.org:443
raw.githubusercontent.com:443
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
Expand Down Expand Up @@ -148,14 +148,14 @@ jobs:
ppa.launchpadcontent.net:443
pypi.org:443
raw.githubusercontent.com:443
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Eigen3
if: contains(matrix.tox-env, 'sbck')
run: |
sudo apt-get update
sudo apt-get install libeigen3-dev
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
Expand Down Expand Up @@ -203,9 +203,9 @@ jobs:
pypi.org:443
raw.githubusercontent.com:443
repo.anaconda.com:443
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/[email protected]
uses: mamba-org/setup-micromamba@e820223f89c8720d6c740ca154a7adf32fcd278a # v1.7.3
with:
cache-downloads: true
cache-environment: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-mastodon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
default: true
type: boolean

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -30,7 +30,7 @@ jobs:
egress-policy: audit

- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Current Version
if: ${{ !github.event.inputs.version-tag }}
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Prepare Message
id: render_template
uses: chuhlomin/[email protected]
uses: chuhlomin/render-template@a473db625a96c98e519d188812dc22bcaf54ffba # v1.9
with:
template: .github/publish-mastodon.template.md
vars: |
Expand All @@ -75,7 +75,7 @@ jobs:

- name: Send toot to Mastodon
if: ${{ github.event.inputs.dry-run != 'true' }} || ${{ github.event_name == 'release' }}
uses: cbrgm/[email protected]
uses: cbrgm/mastodon-github-action@d98ab3376f941df14d37d5737961de431c0838c6 # v1.0.3
with:
message: "${{ steps.render_template.outputs.result }}${{ env.contributors }}"
visibility: "public"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types:
- published

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -21,9 +21,9 @@ jobs:
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python3
uses: actions/[email protected]
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.x"
- name: Install packaging libraries
Expand All @@ -33,4 +33,4 @@ jobs:
run: |
python -m flit build
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # v1.8.11
9 changes: 2 additions & 7 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
schedule:
- cron: '41 8 * * 4'
push:
branches: [ "master" ]
branches:
- master

# Declare default permissions as read only.
permissions: read-all
Expand All @@ -26,9 +27,6 @@ jobs:
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

steps:
- name: Harden Runner
Expand Down Expand Up @@ -56,9 +54,6 @@ jobs:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
tags:
- 'v*'

permissions: # added using https://github.com/step-security/secure-repo
permissions:
contents: read

jobs:
Expand All @@ -21,9 +21,9 @@ jobs:
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit
- uses: actions/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Python3
uses: actions/[email protected]
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.x"
- name: Install packaging libraries
Expand All @@ -33,7 +33,7 @@ jobs:
run: |
python -m flit build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/[email protected]
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # v1.8.11
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
Loading
Loading