Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 860c52e

Browse files
authored
Add CI Security, SAST and OSSF checks (#35)
* Add CI Security, SAST and OSSF checks * Add OSSF Badge
1 parent f3d9e40 commit 860c52e

File tree

4 files changed

+223
-1
lines changed

4 files changed

+223
-1
lines changed

.github/workflows/codeql.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ["main"]
17+
pull_request:
18+
branches: ["main"]
19+
schedule:
20+
- cron: "5 5 * * 3"
21+
22+
jobs:
23+
analyze:
24+
name: Analyze
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners
29+
# Consider using larger runners for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
32+
permissions:
33+
# required for all workflows
34+
security-events: write
35+
36+
# only required for workflows in private repositories
37+
actions: read
38+
contents: read
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
language: ["swift"]
44+
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
45+
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
46+
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
47+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
53+
# Initializes the CodeQL tools for scanning.
54+
- name: Initialize CodeQL
55+
uses: github/codeql-action/init@v3
56+
with:
57+
languages: ${{ matrix.language }}
58+
# If you wish to specify custom queries, you can do so here or in a config file.
59+
# By default, queries listed here will override any specified in a config file.
60+
# Prefix the list here with "+" to use these queries and those in the config file.
61+
62+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
63+
# queries: security-extended,security-and-quality
64+
65+
- name: Bootstrap
66+
run: make bootstrap
67+
68+
- uses: swift-actions/setup-swift@v1
69+
with:
70+
swift-version: "5.9"
71+
72+
- name: Build
73+
run: swift build
74+
75+
# ℹ️ Command-line programs to run using the OS shell.
76+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
77+
78+
# If the Autobuild fails above, remove it and uncomment the following three lines.
79+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
80+
81+
# - run: |
82+
# echo "Run, Build Application using script"
83+
# ./location_of_script_within_repo/buildscript.sh
84+
85+
- name: Perform CodeQL Analysis
86+
uses: github/codeql-action/analyze@v3
87+
with:
88+
category: "/language:${{matrix.language}}"

.github/workflows/scorecard.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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: "5 5 * * 4"
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+
# Uncomment the permissions below if installing in a private repository.
30+
# contents: read
31+
# actions: read
32+
33+
steps:
34+
- name: "Checkout code"
35+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
36+
with:
37+
persist-credentials: false
38+
39+
- name: "Run analysis"
40+
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
41+
with:
42+
results_file: results.sarif
43+
results_format: sarif
44+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
45+
# - you want to enable the Branch-Protection check on a *public* repository, or
46+
# - you are installing Scorecard on a *private* repository
47+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
48+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
49+
50+
# Public repositories:
51+
# - Publish results to OpenSSF REST API for easy access by consumers
52+
# - Allows the repository to include the Scorecard badge.
53+
# - See https://github.com/ossf/scorecard-action#publishing-results.
54+
# For private repositories:
55+
# - `publish_results` will always be set to `false`, regardless
56+
# of the value entered here.
57+
publish_results: true
58+
59+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
60+
# format to the repository Actions tab.
61+
- name: "Upload artifact"
62+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3
63+
with:
64+
name: SARIF file
65+
path: results.sarif
66+
retention-days: 5
67+
68+
# Upload the results to GitHub's code scanning dashboard.
69+
- name: "Upload to code-scanning"
70+
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
71+
with:
72+
sarif_file: results.sarif

.github/workflows/security.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Security Scanning
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
8+
push:
9+
branches:
10+
- main
11+
12+
# Run every day at 5am UTC
13+
schedule:
14+
- cron: "0 5 * * *"
15+
16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
19+
jobs:
20+
snyk:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
26+
with:
27+
ref: ${{ github.head_ref }}
28+
29+
- name: Install Snyk
30+
uses: snyk/actions/setup@master
31+
32+
- name: Snyk VULN and License Check Test
33+
run: snyk test --all-projects --sarif-file-output=snyk.sarif
34+
env:
35+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
36+
37+
- name: Upload SARIF result to GitHub Code Scanning
38+
uses: github/codeql-action/upload-sarif@v2
39+
if: always()
40+
with:
41+
sarif_file: snyk.sarif
42+
43+
fossa:
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
49+
with:
50+
ref: ${{ github.head_ref }}
51+
52+
- name: Run FOSSA Scan
53+
uses: fossas/fossa-action@main
54+
with:
55+
api-key: ${{ secrets.FOSSA_API_KEY }}
56+
57+
- name: Run FOSSA Test
58+
uses: fossas/fossa-action@main
59+
with:
60+
api-key: ${{ secrets.FOSSA_API_KEY }}
61+
run-tests: true

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# tbdex-swift
22

3-
[![SPI Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FTBD54566975%2Ftbdex-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/TBD54566975/tbdex-swift)
3+
[![SPI Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FTBD54566975%2Ftbdex-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/TBD54566975/tbdex-swift)
44
[![SPI Platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FTBD54566975%2Ftbdex-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/TBD54566975/tbdex-swift)
5+
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/TBD54566975/tbdex-swift/badge)](https://securityscorecards.dev/viewer/?uri=github.com/TBD54566975/tbdex-swift)
56

67
> ⚠️ tbDEX SWIFT SDK IS CURRENTLY A WIP! ⚠️
78

0 commit comments

Comments
 (0)