Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup nodesecure #8

Merged
merged 9 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .nodesecureignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"warnings": {
"unsafe-regex": [
"class-validator",
"validator"
],
" unsafe-import": [
"pino"
]
}
}
3 changes: 2 additions & 1 deletion apps/cat-fostering-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.env*
.flaskenv*
!.env.project
!.env.vault
!.env.vault
package-lock.json
6 changes: 3 additions & 3 deletions apps/cat-fostering-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the docker image with `npx nx docker-build cat-fostering-api`.
# Tip: Modify "docker-build" options in project.json to change docker build args.
# Build the docker image with `npx nx run cat-fostering-api:container`.
# Tip: Modify "container" options in project.json to change docker build args.
#
# Run the container with `docker run -e ORY_ACTION_API_KEY='hello' -e POSTGRES_URL='postgres://dbuser:secret@postgres:5432/appdb' --network cat-fostering_ory -p 3000:3000 -t ghcr.io/getlarge/cat-fostering/cat-fostering-api:latest`.

Expand All @@ -12,7 +12,7 @@ WORKDIR /app

RUN echo "Building cat-fostering-api image with NODE_VERSION=$NODE_VERSION"

COPY ./apps/cat-fostering-api/package*.json ./
COPY ./dist/apps/cat-fostering-api/package*.json ./

RUN npm install --omit=dev -f --loglevel=error
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
Expand Down
36 changes: 31 additions & 5 deletions apps/cat-fostering-api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"dockerFiles",
{ "dependentTasksOutputFiles": "**/dist/**/*", "transitive": true }
getlarge marked this conversation as resolved.
Show resolved Hide resolved
],
"cache": true,
"dependsOn": ["lint", "build"],
"options": {
"file": "apps/cat-fostering-api/Dockerfile",
Expand All @@ -59,14 +60,39 @@
"build-args": ["APP_NAME=cat-fostering-api", "NODE_VERSION=20.9.0"]
}
},
"docker-build": {
"generate-lock-file": {
"inputs": ["{projectRoot}/package.json"],
"outputs": ["{projectRoot}/package-lock.json"],
"dependsOn": [
{
"target": "lint",
"params": "forward"
}
],
"cache": true,
"dependsOn": ["lint", "build"],
"command": "npm i --prefix apps/cat-fostering-api --package-lock-only",
"metadata": {
"description": "Generate NPM lock file"
}
},
"nsci": {
"inputs": [
"dockerFiles",
{ "dependentTasksOutputFiles": "**/dist/**/*", "transitive": true }
"{workspaceRoot}/.nodesecurerc",
"{workspaceRoot}/.nodesecureignore",
{
"dependentTasksOutputFiles": "apps/cat-fostering-api/package-lock.json"
}
],
"command": "docker build -f apps/cat-fostering-api/Dockerfile . -t ghcr.io/getlarge/cat-fostering/cat-fostering-api:dev"
"dependsOn": ["generate-lock-file", "build"],
"cache": true,
"executor": "nx:run-commands",
"options": {
"command": "npx nsci --directory=dist/apps/cat-fostering-api --strategy=npm --vulnerabilities=medium run",
"forwardAllArgs": true
},
"metadata": {
"description": "Run the NodeSecure CI analysis"
}
}
}
}
9 changes: 8 additions & 1 deletion apps/cat-fostering-api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ module.exports = {
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ['./src/assets'],
assets: [
'./src/assets',
{
input: './',
glob: './package*.json',
output: '.',
},
],
optimization: false,
outputHashing: 'none',
transformers: [
Expand Down
Loading
Loading