Skip to content

Commit 5e224cc

Browse files
Enable fortify scanning for .NET Framework projects. (#759)
* Enable fortify scanning for .NET Framework projects. * Fix actions name
1 parent e5c678f commit 5e224cc

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
name: Fortify on Demand Scan (.NET Framework)
3+
4+
# TODO: Customize trigger events based on your DevSecOps processes and typical FoD SAST scan time
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- 'master'
10+
- 'beta'
11+
- 'release-*'
12+
#Run at the end of every day
13+
schedule:
14+
- cron: '0 0 * * *'
15+
16+
jobs:
17+
FoD-SAST-Scan:
18+
# Use the appropriate runner for building your source code.
19+
# TODO: Use a Windows runner for .NET Framework projects that use msbuild. Additional changes to RUN commands will be required to switch to Windows syntax.
20+
runs-on: windows-latest
21+
22+
steps:
23+
# Check out source code
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
with:
27+
repository: ''
28+
29+
# Java 8 required by ScanCentral Client and FoD Uploader(Univeral CI Tool)
30+
- name: Setup Java
31+
uses: actions/setup-java@v1
32+
with:
33+
java-version: 1.8
34+
35+
- name: Setup MSBuild
36+
uses: microsoft/setup-msbuild@v1
37+
with:
38+
vs-version: 10.0
39+
40+
- name: Create temporal solution
41+
run: |
42+
$fortifysolution = "FortifySolution"
43+
dotnet new sln --name $fortifysolution --output dotnet --force
44+
dotnet msbuild dotnet\DotNetStandardClasses.sln /t:DumpProjects -p:DumpSolutionName=$fortifysolution /m:1 -p:DumpSolutionTargetFrameworkDefault=net4
45+
46+
# Prepare source+dependencies for upload. The default example is for a Maven project that uses pom.xml.
47+
# TODO: Update PACKAGE_OPTS based on the ScanCentral Client documentation for your project's included tech stack(s). Helpful hints:
48+
# ScanCentral Client will download dependencies for maven (-bt mvn) and gradle (-bt gradle).
49+
# ScanCentral Client can download dependencies for msbuild projects (-bt msbuild); however, you must convert the workflow to use a Windows runner.
50+
# ScanCentral has additional options that should be set for PHP and Python projects
51+
# For other build tools, add your build commands to download necessary dependencies and prepare according to Fortify on Demand Packaging documentation.
52+
# ScanCentral Client documentation is located at https://www.microfocus.com/documentation/fortify-software-security-center/
53+
- name: Download Fortify ScanCentral Client
54+
uses: fortify/gha-setup-scancentral-client@v1
55+
- name: Package Code + Dependencies
56+
run: scancentral package -bt msbuild -bf ./dotnet/FortifySolution.sln -o package.zip
57+
58+
- name: Show package contents
59+
run: unzip -v package.zip
60+
61+
# Start Fortify on Demand SAST scan and wait until results complete. For more information on FoDUploader commands, see https://github.com/fod-dev/fod-uploader-java
62+
# TODO: Update ENV variables for your application and create the necessary GitHub Secrets. Helpful hints:
63+
# Credentials and release ID should be obtained from your FoD tenant (either Personal Access Token or API Key can be used).
64+
# Automated Audit preference should be configured for the release's Static Scan Settings in the Fortify on Demand portal.
65+
- name: Download Fortify on Demand Universal CI Tool
66+
uses: fortify/gha-setup-fod-uploader@v1.0.1
67+
- name: Perform SAST Scan
68+
run: java -jar ${env:FOD_UPLOAD_JAR} -z package.zip -aurl ${env:FOD_API_URL} -purl ${env:FOD_URL} -rid "${env:FOD_RELEASE_ID}" -tc "${env:FOD_TENANT}" -ac "${env:FOD_USER}" "${env:FOD_PAT}" -ep 2 -pp 1 -I 1 -apf -n "${env:FOD_UPLOADER_NOTES}"
69+
70+
env:
71+
FOD_TENANT: ${{ secrets.FOD_TENANT }}
72+
FOD_USER: ${{ secrets.FOD_USER }}
73+
FOD_PAT: ${{ secrets.FOD_PAT }}
74+
FOD_RELEASE_ID: ${{ secrets.FOD_RELEASE_ID }}
75+
FOD_URL: "https://ams.fortify.com"
76+
FOD_API_URL: "https://api.ams.fortify.com"
77+
FOD_UPLOADER_NOTES: 'Triggered by GitHub Actions (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
78+
79+
# Once scan completes, pull SAST issues from Fortify on Demand and generate SARIF output.
80+
- name: Export Results
81+
uses: fortify/gha-export-vulnerabilities@v1.0.2
82+
with:
83+
export_target: GitHub
84+
fod_base_url: "https://ams.fortify.com/"
85+
fod_tenant: ${{ secrets.FOD_TENANT }}
86+
fod_client_id: ${{ secrets.FOD_USER }}
87+
fod_client_secret: ${{ secrets.FOD_PAT }}
88+
fod_release_id: ${{ secrets.FOD_RELEASE_ID }}
89+
90+
- name: Patch sarif file
91+
run: |
92+
(Get-Content -Path gh-fortify-sast.sarif) |
93+
ForEach-Object { $_ -Replace '"startLine" : 0', '"startLine" : 1' } |
94+
Set-Content gh-fortify-sast-patched.sarif
95+
96+
# Import Fortify on Demand results to GitHub Security Code Scanning
97+
- name: Import Results
98+
uses: github/codeql-action/upload-sarif@v2
99+
with:
100+
sarif_file: ./gh-fortify-sast-patched.sarif

.github/workflows/fortify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
name: Fortify on Demand Scan
2+
name: Fortify on Demand Scan (.NET)
33

44
# TODO: Customize trigger events based on your DevSecOps processes and typical FoD SAST scan time
55
on:

0 commit comments

Comments
 (0)