Skip to content

Commit

Permalink
OSSF patch (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Titsworth authored Feb 26, 2024
2 parents 70e752f + c1746c5 commit b90a914
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .github/utils/val-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ input_string="$1"

# Use regex to find the line that contains '/test-group' and capture it
if [[ $input_string =~ /test-group(.*) ]]; then
matched_line="${BASH_REMATCH[1]}"
matched_line="${BASH_REMATCH[1]}"
else
# If the pattern is not found, exit
echo "Error: The input string does not contain a line with '/test-group'."
exit 1
# If the pattern is not found, exit
echo "Error: The input string does not contain a line with '/test-group'."
exit 1
fi

# Use regex to extract key-value pairs with the cases:
Expand All @@ -21,10 +21,10 @@ key_val_pairs=$(echo "$matched_line" | grep -oP "$regex" | sed 's/: /=/g')

# Check if there is at least one key-value pair
if [[ -z "$key_val_pairs" ]]; then
echo "Error: The matched line does not contain any valid key-value pairs."
exit 1
echo "Error: The matched line does not contain any valid key-value pairs."
exit 1
fi

# Print the key-value pairs
echo "$key_val_pairs"
echo "$key_val_pairs" >> "$GITHUB_OUTPUT"
echo "$key_val_pairs" >>"$GITHUB_OUTPUT"
7 changes: 5 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Super-linter
uses: super-linter/super-linter/slim@v5.7.2
uses: super-linter/super-linter/slim@v6.2.0
env:
DEFAULT_BRANCH: main
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
GITHUB_ACTIONS_COMMAND_ARGS: '-ignore SC.*'
VALIDATE_BASH_EXEC: false
VALIDATE_CHECKOV: false
VALIDATE_KUBERNETES_KUBECONFORM: false
VALIDATE_NATURAL_LANGUAGE: false
VALIDATE_PYTHON_FLAKE8: false
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/ossf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '29 17 * * 4'
push:
branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: k8-runners
permissions:
# Needed to upload the results to code-scanning dashboard.
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: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
repo_token: ${{ secrets.ACTION_TOKEN }}

# Public repositories:
# - 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
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
with:
sarif_file: results.sarif
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ repos:
rev: v0.9.0
hooks:
- id: shellcheck
- repo: https://github.com/cisagov/pre-commit-shfmt
rev: v0.0.2
hooks:
- id: shfmt
- repo: https://github.com/ambv/black
rev: 23.12.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This project follows the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.
2. Create a new branch for your contribution: `git checkout -b feature/your-feature`.
3. Install [pre-commit](https://pre-commit.com/), [Docker](https://docs.docker.com/engine/install/), and [Python 3.8+](https://www.python.org/downloads/).
4. Follow the [Project Setup](README.md#project-setup) steps.
5. Install the third-party python dependencies necessary for pre-commit with `pip install pytest pylint black`.
5. Install the third-party python dependencies necessary for pre-commit with `pip install pytest pylint black shfmt-py`.
6. Make your changes, commit, and sign your changes: `git commit -s -m 'Add your feature'`.
7. Push to the branch: `git push origin feature/your-feature`.
8. Submit a pull request.
Expand Down
1 change: 0 additions & 1 deletion classical-ml/tests/sklearn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# For reference:
# https://docs.docker.com/develop/develop-images/build_enhancements/


wget https://raw.githubusercontent.com/intel/ai-containers/main/preset/classical-ml/tests/scikit/kmeans.py
python kmeans.py true

Expand Down

0 comments on commit b90a914

Please sign in to comment.