-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into haskell-fuzz
- Loading branch information
Showing
21 changed files
with
336 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
checks/testdata/.github/workflows/github-workflow-permissions-secevent-known-actions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2021 OpenSSF Scorecard Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
name: write-and-read workflow | ||
on: [push] | ||
permissions: read-all | ||
|
||
# All of the actions below are known to upload SARIF. | ||
# They should not trigger a warning about the security-events | ||
# write permission being enabled. | ||
jobs: | ||
codeql-analyze: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
steps: | ||
- uses: github/codeql-action/analyze@v1 | ||
|
||
codeql-upload: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
steps: | ||
- uses: github/codeql-action/upload-sarif@v1 | ||
|
||
scorecard: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
steps: | ||
- uses: ossf/scorecard-action@v1 | ||
|
||
haskell-hlint: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
steps: | ||
- uses: haskell-actions/hlint-scan@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Configuring a local environment to test the Scorecard Cron Job | ||
|
||
This emulator focuses on being able to test the `worker`, which pulls messages from a pubsub, processes them, and writes the results to a Google Cloud Storage (GCS) bucket. | ||
It's necessary to support pubsub, gcs, and the `controller` to get the `worker` working. | ||
|
||
In general, you'll need 4-5 terminals (or tmux) to run everything needed. | ||
|
||
## GCS emulator | ||
|
||
[fake-gcs-server](https://github.com/fsouza/fake-gcs-server) meets our needs and is written in Go. | ||
We may be able to use it as a library for unit tests in the future. | ||
|
||
For now, the binary is good enough, so install it from source (or [Releases](https://github.com/fsouza/fake-gcs-server/releases)): | ||
|
||
``` | ||
go install github.com/fsouza/fake-gcs-server@latest | ||
``` | ||
|
||
Now you can run the fake from the root of the Scorecard repo in your first window: | ||
``` | ||
fake-gcs-server -scheme http -public-host 0.0.0.0:4443 \ | ||
-backend filesystem -filesystem-root cron/internal/emulator/fakegcs | ||
``` | ||
|
||
## pubsub emulator: | ||
Google Cloud has a [pubsub emulator](https://cloud.google.com/pubsub/docs/emulator) with complete install ininstructions. | ||
I've summarized some of them below. | ||
|
||
|
||
### One time setup | ||
|
||
``` | ||
gcloud components install pubsub-emulator | ||
gcloud components update | ||
``` | ||
|
||
Anywhere outside your scorecard repo: | ||
``` | ||
git clone https://github.com/googleapis/python-pubsub | ||
cd python-pubsub/samples/snippet | ||
pip install -r requirements.txt | ||
``` | ||
|
||
### Running the pubsub emulator (needed to do everytime) | ||
|
||
In a second window from any directory, run the emulator itself: | ||
|
||
``` | ||
export PUBSUB_PROJECT_ID=test | ||
gcloud beta emulators pubsub start --project=$PUBSUB_PROJECT_ID | ||
``` | ||
|
||
In a third window (from the `samples/snippet` directory wherever you cloned `python-pubsub`) create the topic and subscription: | ||
|
||
``` | ||
export PUBSUB_PROJECT_ID=test | ||
export TOPIC_ID=scorecard-batch-requests | ||
export SUBSCRIPTION_ID=scorecard-batch-worker | ||
$(gcloud beta emulators pubsub env-init) | ||
python3 publisher.py $PUBSUB_PROJECT_ID create $TOPIC_ID | ||
python3 subscriber.py $PUBSUB_PROJECT_ID create $TOPIC_ID $SUBSCRIPTION_ID | ||
alias drain-pubsub="python3 subscriber.py $PUBSUB_PROJECT_ID receive $SUBSCRIPTION_ID" | ||
``` | ||
|
||
At any point you can drain the queue by running the following in the same window. Make sure to stop the command when testing the `worker`: | ||
``` | ||
drain-pubsub | ||
``` | ||
|
||
## run Scorecard cron components | ||
|
||
Commands intended to be run from the base of the Scorecard repo. Since this is intended to be used during development, `go run` is used but there's no reason you can't use `go build`. | ||
The repos in `cron/internal/emulator/projects.csv` and the `cron/internal/emulator/config.yaml` file can be changed as needed. | ||
|
||
### controller | ||
``` | ||
$(gcloud beta emulators pubsub env-init) | ||
export STORAGE_EMULATOR_HOST=0.0.0.0:4443 | ||
go run $(ls cron/internal/controller/*.go | grep -v _test.go) \ | ||
--config cron/internal/emulator/config.yaml \ | ||
cron/internal/emulator/projects.csv | ||
``` | ||
|
||
### worker | ||
``` | ||
$(gcloud beta emulators pubsub env-init) | ||
export STORAGE_EMULATOR_HOST=0.0.0.0:4443 | ||
go run $(ls cron/internal/worker/*.go | grep -v _test.go) \ | ||
--ignoreRuntimeErrors=true \ | ||
--config cron/internal/emulator/config.yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2023 OpenSSF Scorecard Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
project-id: test | ||
request-topic-url: gcppubsub://projects/test/topics/scorecard-batch-requests | ||
request-subscription-url: gcppubsub://projects/test/subscriptions/scorecard-batch-worker | ||
bigquery-dataset: scorecardcron | ||
bigquery-table: scorecard-v2 | ||
completion-threshold: 0.99 | ||
shard-size: 10 | ||
webhook-url: | ||
metric-exporter: printer | ||
metric-stackdriver-prefix: scorecard-cron | ||
result-data-bucket-url: gs://ossf-scorecard-data2 | ||
|
||
additional-params: | ||
input-bucket: | ||
url: gs://ossf-scorecard-input-projects | ||
# Optional prefix to limit files used as input files within a bucket (e.g. a specific file or directory) | ||
prefix: | ||
# Optional file to read a prefix from, instead of statically defining prefix above (note: prefix must be blank to use this option) | ||
# This is good in situations where the prefix changes frequently (e.g. always using the most recent folder in a bucket) | ||
prefix-file: | ||
|
||
scorecard: | ||
# API results bucket | ||
api-results-bucket-url: gs://ossf-scorecard-cron-results | ||
# TODO: Temporarily remove SAST and CI-Tests which require lot of GitHub API tokens. | ||
# TODO(#859): Re-add Contributors after fixing inconsistencies. | ||
# TODO: Dependency-Update-Tool and SAST are search heavy | ||
# TODO: Vulnerabilities is slow on repos with lots of dependencies | ||
blacklisted-checks: CI-Tests,Contributors,Dependency-Update-Tool,SAST,Vulnerabilities | ||
cii-data-bucket-url: gs://ossf-scorecard-cii-data | ||
# Raw results. | ||
raw-bigquery-table: scorecard-rawdata | ||
raw-result-data-bucket-url: gs://ossf-scorecard-rawdata |
2 changes: 2 additions & 0 deletions
2
cron/internal/emulator/fakegcs/ossf-scorecard-cii-data/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
2 changes: 2 additions & 0 deletions
2
cron/internal/emulator/fakegcs/ossf-scorecard-cron-results/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
2 changes: 2 additions & 0 deletions
2
cron/internal/emulator/fakegcs/ossf-scorecard-data2/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
2 changes: 2 additions & 0 deletions
2
cron/internal/emulator/fakegcs/ossf-scorecard-rawdata/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
repo,metadata | ||
github.com/ossf/scorecard, | ||
github.com/ossf/scorecard-action, | ||
github.com/ossf/scorecard-webapp, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.