Skip to content

Commit ba82041

Browse files
author
kadraman
committed
Updating makefile
1 parent 1d100d4 commit ba82041

2 files changed

Lines changed: 55 additions & 19 deletions

File tree

Makefile

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@
33
ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
44
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
55
PROJECT := InsecureRestAPI
6+
PROJECT_LOWER := $(shell echo $(PROJECT) | tr '[:upper:]' '[:lower:]')
67
PROJECTS := $(shell ls . | grep project)
78
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo "1.0.0")
89
COMMIT := $(shell git log -1 --pretty=format:"%H")
10+
UNAME := $(shell uname)
911

1012
FLASK_APP := iwa
11-
FLASK := FLASK_APP=$(FLASK_APP) .venv/bin/flask
1213

1314
SAST_DEFAULT_OPTS := -Dcom.fortify.sca.ProjectRoot=.fortify -b "$(PROJECT)"
14-
SAST_TRANSLATE_OPTS := $(SAST_DEFAULT_OPTS) .
1515
SAST_SCAN_OPTS := $(SAST_DEFAULT_OPTS)
16+
ifeq ($(OS),Windows_NT)
17+
SAST_TRANSLATE_OPTS := $(SAST_DEFAULT_OPTS) iwa
18+
SAST_CUSTOM_RULES := etc\\sast-custom-rules\\example-custom-rules.xml
19+
SAST_FILTER := etc\\sast-filters\\example-filter.txt
20+
else
21+
SAST_TRANSLATE_OPTS := $(SAST_DEFAULT_OPTS) iwa
22+
SAST_CUSTOM_RULES := $(ROOT_DIR)/etc/sast-custom-rules/example-custom-rules.xml
23+
SAST_FILTER := $(ROOT_DIR)/etc/sast-filters/example-filter.txt
24+
endif
1625

1726
.PHONY: default
1827
default: help
@@ -21,6 +30,11 @@ default: help
2130
.PHONY: help
2231
help: ## help information about make commands
2332
@grep -h -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
33+
ifeq ($(OS),Windows_NT)
34+
@echo Running on Windows: $(OS)
35+
else
36+
@echo Running on Linux/UNIX: $(UNAME)
37+
endif
2438

2539
.PHONY: version
2640
version: ## display the version of the service
@@ -29,6 +43,7 @@ version: ## display the version of the service
2943
.PHONY: build
3044
build: ## build the project
3145
@echo "Building $(PROJECT)..."
46+
npm install
3247
npm run swagger
3348
npm run build
3449

@@ -54,22 +69,34 @@ test: ## run unit tests for the project
5469

5570
.PHONY: clean
5671
clean: ## remove temporary files
72+
ifeq ($(OS),Windows_NT)
73+
cmd /c "rmdir /s /q instance node-modules .fortify"
74+
else
5775
rm -rf instance node-modules .fortify *.lock *.fpr
76+
endif
5877

5978
.PHONY: sast-scan
6079
sast-scan: ## run OpenText static application security testing
6180
@echo "Running OpenText static application security testing..."
62-
@sourceanalyzer $(SAST_DEFAULT_OPTS) -clean
63-
@sourceanalyzer $(SAST_TRANSLATE_OPTS)
64-
@sourceanalyzer $(SAST_SCAN_OPTS) -scan \
65-
-rules $(ROOT_DIR)/etc/sast-custom-rules/example-custom-rules.xml \
66-
-filter $(ROOT_DIR)/etc/sast-filters/example-filter.txt \
81+
sourceanalyzer $(SAST_DEFAULT_OPTS) -clean
82+
sourceanalyzer $(SAST_TRANSLATE_OPTS)
83+
sourceanalyzer $(SAST_SCAN_OPTS) -scan \
84+
-rules $(SAST_CUSTOM_RULES) \
85+
-filter $(SAST_FILTER) \
6786
-build-project "$(PROJECT)" -build-version "$(VERSION)" -build-label "SNAPSHOT" \
6887
-f "$(PROJECT).fpr"
69-
@FPRUtility -information -analyzerIssueCounts -project "$(PROJECT).fpr"
88+
ifeq ($(OS),Windows_NT)
89+
cmd /c "FPRUtility -information -analyzerIssueCounts -project $(PROJECT).fpr"
90+
else
91+
FPRUtility -information -analyzerIssueCounts -project "$(PROJECT).fpr"
92+
endif
7093

7194
.PHONY: sca-scan
7295
sca-scan: ## run OpenText software composition analysis
7396
@echo "Running OpenText software composition analysis..."
74-
@debricked scan . -r $(PROJECT) -c $(COMMIT) -t $(DEBRICKED_TOKEN)
97+
debricked scan . -r $(PROJECT) -c $(COMMIT) -t $(DEBRICKED_TOKEN)
7598

99+
.PHONY: nexus-iq-scan
100+
nexus-iq-scan: ## run Sonatype Nexus IQ software composition analysis
101+
@echo "Running Sonatype Nexusi IQ software composition analysis..."
102+
nexus-iq-cli -i $(PROJECT_LOWER) -s $(NEXUS_IQ_URL) -a "$(NEXUS_IQ_USERNAME):$(NEXUS_IQ_PASSWORD)" package-lock.json

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
# InsecureRestAPI
44

5-
_InsecureRestAPI_ is a simple NodeJS/Express/MongoFB REST API fthat can be used for the demonstration of Application Security testing tools - such as [OpenText Application Security](https://www.opentext.com/products/application-security).
5+
_InsecureRestAPI_ is a simple NodeJS/Express/MongoFB REST API that can be used for the demonstration of Application Security testing tools - such as [OpenText Application Security](https://www.opentext.com/products/application-security).
66

77
Pre-requisities
88
---------------
99

10-
- Windows or Linux machine with Node 20 or later
11-
- [node package manager](https://docs.npmjs.com/about-npm)
12-
- [GNU Make](https://www.gnu.org/software/make/)
13-
- [MongoDB](https://www.mongodb.com/) Community Edition (optional)
10+
- [Node.js 20 or later](https://nodejs.org/en/download)
11+
- [CygWin](https://www.cygwin.com/) - if running on Windows
12+
- [MongoDB](https://www.mongodb.com/) Community Edition (optional as a version is embedded for testing)
1413
- Docker installation (optional)
1514

1615
Run Application (locally)
@@ -20,9 +19,8 @@ You can the run the application locally using the following:
2019

2120

2221
```
23-
npm i
24-
npm i -g ts-node-dev
25-
npm run dev
22+
npm install -g ts-node-dev
23+
make run
2624
```
2725

2826
The API should then be available at the URL `http://localhost:5000`. If it fails to start,
@@ -34,7 +32,7 @@ Run Application (as Docker container)
3432
You also can build a Docker image for the application using the following:
3533

3634
```
37-
npm run build
35+
make build
3836
docker build -t demoapi:latest .
3937
```
4038

@@ -50,7 +48,18 @@ make sure you have no other applications running on port 8080.
5048
Using the API
5149
-------------
5250

53-
Most of the API operations do not require authentication.
51+
You can use the Swagger Documentation to test the API endpoints.
52+
First login as a user using the endpoint "/api/v1/site/sign-in" and either of the following credentials
53+
54+
- email: user1@localhost.com
55+
password: password
56+
- email: admin@localhost.com
57+
password: password
58+
59+
Then copy the value of the `accessToken` returned. Go back to the top of the page. Click on **Authorize**
60+
and enter this value.
61+
62+
There are also some example [Postman](https://www.postman.com/downloads/) collections in the `etc` directory.
5463

5564
Scan Application (with OpenText Application Security)
5665
-----------------------------------------------------

0 commit comments

Comments
 (0)