Skip to content

Commit aba26b4

Browse files
author
kadraman
committed
Updating Actions and source headers
1 parent efd8642 commit aba26b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+460
-1703
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
22
# More GitHub Actions for Azure: https://github.com/Azure/actions
33

4-
name: Build and deploy Node.js app to Azure Web App
4+
name: Build and Deploy to Azurepermissions:
5+
# required for all workflows
6+
security-events: write
7+
# required to fetch internal or private CodeQL packs
8+
packages: read
9+
# only required for workflows in private repositories
10+
actions: read
11+
contents: read
512

613
on:
714
push:

.github/workflows/codeql.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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 Advanced"
13+
14+
on:
15+
# Triggers the workflow on push or pull request events but only for the main or develop branches
16+
push:
17+
paths-ignore:
18+
- '.github/**/**'
19+
- 'Jenkinsfile'
20+
- '.gitlab-ci.yml'
21+
- 'azure-pipelines.yml'
22+
- 'bin/**'
23+
- 'data/**'
24+
- 'etc/**'
25+
- 'tests/**'
26+
- '*.md'
27+
- 'LICENSE'
28+
#branches-ignore:
29+
# - main
30+
# - develop
31+
branches:
32+
- '**' # matches every branch
33+
pull_request:
34+
branches: [ main, develop ]
35+
36+
jobs:
37+
analyze:
38+
# only run this job if the repository is origin 'kadraman/InsecureRestAPI not forked repositories
39+
if: ${{ github.repository == 'kadraman/InsecureRestAPI' }}
40+
name: Analyze (${{ matrix.language }})
41+
# Runner size impacts CodeQL analysis time. To learn more, please see:
42+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
43+
# - https://gh.io/supported-runners-and-hardware-resources
44+
# - https://gh.io/using-larger-runners (GitHub.com only)
45+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
46+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
47+
permissions:
48+
# required for all workflows
49+
security-events: write
50+
51+
# required to fetch internal or private CodeQL packs
52+
packages: read
53+
54+
# only required for workflows in private repositories
55+
actions: read
56+
contents: read
57+
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
include:
62+
- language: actions
63+
build-mode: none
64+
- language: javascript-typescript
65+
build-mode: none
66+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
67+
# Use `c-cpp` to analyze code written in C, C++ or both
68+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
69+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
70+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
71+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
72+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
73+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
74+
steps:
75+
- name: Checkout repository
76+
uses: actions/checkout@v4
77+
78+
# Add any setup steps before running the `github/codeql-action/init` action.
79+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
80+
# or others). This is typically only required for manual builds.
81+
# - name: Setup runtime (example)
82+
# uses: actions/setup-example@v1
83+
84+
# Initializes the CodeQL tools for scanning.
85+
- name: Initialize CodeQL
86+
uses: github/codeql-action/init@v3
87+
with:
88+
languages: ${{ matrix.language }}
89+
build-mode: ${{ matrix.build-mode }}
90+
# If you wish to specify custom queries, you can do so here or in a config file.
91+
# By default, queries listed here will override any specified in a config file.
92+
# Prefix the list here with "+" to use these queries and those in the config file.
93+
94+
# 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
95+
# queries: security-extended,security-and-quality
96+
97+
# If the analyze step fails for one of the languages you are analyzing with
98+
# "We were unable to automatically build your code", modify the matrix above
99+
# to set the build mode to "manual" for that language. Then modify this step
100+
# to build your code.
101+
# ℹ️ Command-line programs to run using the OS shell.
102+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
103+
- if: matrix.build-mode == 'manual'
104+
shell: bash
105+
run: |
106+
echo 'If you are using a "manual" build mode for one or more of the' \
107+
'languages you are analyzing, replace this with the commands to build' \
108+
'your code, for example:'
109+
echo ' make bootstrap'
110+
echo ' make release'
111+
exit 1
112+
113+
- name: Perform CodeQL Analysis
114+
uses: github/codeql-action/analyze@v3
115+
with:
116+
category: "/language:${{matrix.language}}"

.github/workflows/debricked.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
# Create GitHub Action Secrets for your version of the application:
3+
# DEBRICKEN_TOKEN should be an API Access Token from your Debricked tenant.
4+
5+
name: OSS SCA with Debricked
6+
permissions:
7+
# required for all workflows
8+
security-events: write
9+
# required to fetch internal or private CodeQL packs
10+
packages: read
11+
# only required for workflows in private repositories
12+
actions: read
13+
contents: read
14+
15+
on:
16+
# Triggers the workflow on push or pull request events but only for the main and dev branches
17+
push:
18+
paths:
19+
- '**/package.json'
20+
branches:
21+
- '**' # matches every branch
22+
pull_request:
23+
branches: [ main, develop ]
24+
25+
# Allows you to run this workflow manually from the Actions tab
26+
workflow_dispatch:
27+
inputs:
28+
runDebrickedScan:
29+
description: 'Carry out SCA scan using Debricked'
30+
required: true
31+
default: 'true'
32+
33+
# Global environment variables
34+
env:
35+
DEFAULT_APP_NAME: "InsecureRestAPI"
36+
37+
jobs:
38+
39+
Debricked-SCA:
40+
runs-on: ubuntu-latest
41+
if: ${{ (github.event_name == 'push') || (github.event_name == 'pull_request') || (github.event.inputs.runDebrickedScan == 'true') }}
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
with:
46+
# Fetch at least the immediate parents so that if this is a pull request then we can checkout the head.
47+
fetch-depth: 2
48+
# Java is required to run the various Fortify utilities.
49+
# Setup JDK 11 on host
50+
- uses: actions/setup-java@v4
51+
with:
52+
distribution: 'temurin'
53+
java-version: '11'
54+
# Install Fortify (if required)
55+
- name: Setup Fortify tools
56+
uses: fortify/github-action/setup@v1.2.2
57+
with:
58+
export-path: true
59+
fcli: latest
60+
# Run debricked scan
61+
- name: Download Debricked CLI
62+
run: curl -L https://github.com/debricked/cli/releases/latest/download/cli_linux_x86_64.tar.gz | tar -xz debricked
63+
- name: Run Debricked scan
64+
run: ./debricked scan -r "${APP_NAME}" --access-token="${DEBRICKED_TOKEN}" -e "*/**.lock" -e "**/build/classes/test/**" -e "**/target/classes/test-classes/**" .
65+
env:
66+
APP_NAME: ${{ env.DEFAULT_APP_NAME }}
67+
DEBRICKED_TOKEN: ${{ secrets.DEBRICKED_TOKEN }}

.github/workflows/fod.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,17 @@ permissions:
2727
on:
2828
# Triggers the workflow on push or pull request events but only for the main or develop branches
2929
push:
30-
paths:
31-
- 'src/**'
30+
paths-ignore:
31+
- '.github/**/**'
32+
- 'Jenkinsfile'
33+
- '.gitlab-ci.yml'
34+
- 'azure-pipelines.yml'
35+
- 'bin/**'
36+
- 'data/**'
37+
- 'etc/**'
38+
- 'tests/**'
39+
- '*.md'
40+
- 'LICENSE'
3241
#branches-ignore:
3342
# - main
3443
# - develop
@@ -59,10 +68,10 @@ on:
5968

6069
# Global environment variables
6170
env:
62-
DEFAULT_APP_NAME: "IWA-API-Node"
71+
DEFAULT_APP_NAME: "InsecureRestAPI"
6372
DEFAULT_SOURCE_DIR: "."
6473
AZURE_WEBAPP_NAME: insecureapi
65-
NODE_VERSION: 18
74+
NODE_VERSION: 20
6675

6776
jobs:
6877

@@ -144,11 +153,10 @@ jobs:
144153
FOD_RELEASE: ${{ format('{0}{1}:{2}', env.DEFAULT_APP_NAME, vars.FORTIFY_APP_NAME_POSTFIX, github.ref_name) }}
145154
# DO_SETUP: true
146155
# SETUP_ACTION: https://scm.my.org/shared-repos/fcli-actions/setup.yaml
147-
SETUP_EXTRA_OPTS: ${{ format('--copy-from "{0}" --sdlc-status Development --app-owner {1} --assessment-type "{2}"', env.FOD_PARENT_RELEASE, vars.FOD_DEFAULT_OWNER, vars.FOD_DEFAULT_ASSESSMENT_TYPE) }}
148-
#SETUP_EXTRA_OPTS: "--use-aviator --technology-stack=JS/TS/HTML"
156+
SETUP_EXTRA_OPTS: ${{ format('--copy-from "{0}" --sdlc-status Development --app-owner {1} --assessment-type "{2}" --user-aviator --technology-stack=JS/TS/HTML', env.FOD_PARENT_RELEASE, vars.FOD_DEFAULT_OWNER, vars.FOD_DEFAULT_ASSESSMENT_TYPE) }}
149157
# SC_CLIENT_VERSION: 24.4.1
150158
# DO_PACKAGE_DEBUG: true
151-
PACKAGE_EXTRA_OPTS: "-bt none -oss"
159+
PACKAGE_EXTRA_OPTS: "-bt none"
152160
# FOD_SAST_SCAN_EXTRA_OPTS:
153161
# DO_WAIT: true
154162
DO_POLICY_CHECK: false # we will do this later after SCA and DAST scan

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,4 @@ dist
139139
logs
140140
email-db.json
141141
iwa.db
142+
*.fpr

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ RUN npm install
2424
# Bundle app source
2525
ADD dist ./
2626
COPY config ./config/
27-
COPY mongodb ./mongodb/
2827

29-
# Make port 3000 available to the world outside this container
30-
EXPOSE 3000
28+
# Make port 5000 available to the world outside this container
29+
EXPOSE 5000
3130

3231
CMD [ "node", "index.js" ]
3332

Makefile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
-include .env
2+
3+
ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
4+
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
5+
PROJECT := InsecureRestAPI
6+
PROJECTS := $(shell ls . | grep project)
7+
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo "1.0.0")
8+
COMMIT := $(shell git log -1 --pretty=format:"%H")
9+
10+
FLASK_APP := iwa
11+
FLASK := FLASK_APP=$(FLASK_APP) .venv/bin/flask
12+
13+
SAST_DEFAULT_OPTS := -Dcom.fortify.sca.ProjectRoot=.fortify -b "$(PROJECT)"
14+
SAST_TRANSLATE_OPTS := $(SAST_DEFAULT_OPTS) .
15+
SAST_SCAN_OPTS := $(SAST_DEFAULT_OPTS)
16+
17+
.PHONY: default
18+
default: help
19+
20+
# generate help info from comments
21+
.PHONY: help
22+
help: ## help information about make commands
23+
@grep -h -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
24+
25+
.PHONY: version
26+
version: ## display the version of the service
27+
@echo $(VERSION)
28+
29+
.PHONY: build
30+
build: ## build the project
31+
@echo "Building $(PROJECT)..."
32+
npm build
33+
34+
.PHONY: build-docker
35+
build-docker: ## build the project as a docker image
36+
docker build -f Dockerfile -t $(PROJECT):$(VERSION) .
37+
38+
.PHONY: run
39+
run: ## run the project
40+
@echo "Running $(PROJECT)..."
41+
npm run dev
42+
43+
.PHONY: run-production
44+
run-production: ## run the project in production mode
45+
@echo "Running $(PROJECT) in production mode..."
46+
npm run start
47+
48+
.PHONY: test
49+
test: ## run unit tests for the project
50+
@echo "Testing $(PROJECT)..."
51+
npm run test
52+
53+
.PHONY: clean
54+
clean: ## remove temporary files
55+
rm -rf instance node-modules .fortify *.lock *.fpr
56+
57+
.PHONY: sast-scan
58+
sast-scan: ## run OpenText static application security testing
59+
@echo "Running OpenText static application security testing..."
60+
@sourceanalyzer $(SAST_DEFAULT_OPTS) -clean
61+
@sourceanalyzer $(SAST_TRANSLATE_OPTS)
62+
@sourceanalyzer $(SAST_SCAN_OPTS) -scan \
63+
-rules $(ROOT_DIR)/etc/sast-custom-rules/example-custom-rules.xml \
64+
-filter $(ROOT_DIR)/etc/sast-filters/example-filter.txt \
65+
-build-project "$(PROJECT)" -build-version "$(VERSION)" -build-label "SNAPSHOT" \
66+
-f "$(PROJECT).fpr"
67+
@FPRUtility -information -analyzerIssueCounts -project "$(PROJECT).fpr"
68+
69+
.PHONY: sca-scan
70+
sca-scan: ## run OpenText software composition analysis
71+
@echo "Running OpenText software composition analysis..."
72+
@debricked scan . -r $(PROJECT) -c $(COMMIT) -t $(DEBRICKED_TOKEN)
73+

0 commit comments

Comments
 (0)