Skip to content

Commit

Permalink
Reference pull request for full details.
Browse files Browse the repository at this point in the history
  • Loading branch information
crodriguez6497 committed May 30, 2024
1 parent e484b35 commit 6185afa
Show file tree
Hide file tree
Showing 45 changed files with 509 additions and 428 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.git
.gitignore
.svn
.DS_Store
.vscode
*.log
*.tmp
*.swp
**/README.md
**/node_modules
client/dist
client/.angular
client/.nx
8 changes: 4 additions & 4 deletions C-PAT/C-PAT.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "C-PAT",
"name": "C-PAT",
"organization": "Naval Surface Warfare Center Crane Division, IN (NSWC-Crane)",
"description": "C-PAT is an API and web client developed through Naval Surface Warfare Center Crane Division that aims to automate vulnerability documentation and tracking.",
"description": "C-PAT is an API and web client developed through Naval Surface Warfare Center Crane Division that aims to automate vulnerability documentation and tracking.",
"tags": [
"Plan of Action and Milestones",
"POAM",
Expand All @@ -26,14 +26,14 @@
"licenses": [
{
"URL": "https://github.com/NSWC-Crane/C-PAT/blob/main/LICENSE.md",
"name": "C-PAT SOFTWARE OPEN SOURCE LICENSE AGREEMENT"
"name": "C-PAT SOFTWARE OPEN SOURCE LICENSE AGREEMENT"
}
],
"usageType": "openSource",
"exemptionText": null
},
"laborHours": 3000,
"version": "1.55.0-alpha",
"version": "0.2.0-alpha",
"date": {
"created": "2023-06-01",
"lastModified": "2024-04-24",
Expand Down
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG BASE_IMAGE="node:lts"
FROM ${BASE_IMAGE} as build
ARG COMMIT_BRANCH="unspecified"
ARG COMMIT_SHA="unspecified"
ARG COMMIT_TAG="unspecified"
ARG COMMIT_DESCRIBE="unspecified"
LABEL commit-branch=${COMMIT_BRANCH}
LABEL commit-sha=${COMMIT_SHA}
LABEL commit-tag=${COMMIT_TAG}
LABEL commit-describe=${COMMIT_DESCRIBE}

WORKDIR /app/client

COPY client/package*.json ./

RUN npm install --force

COPY client/. .

RUN npm run build

FROM node:lts

WORKDIR /app/api

COPY api/package*.json ./

RUN npm install

COPY api/. .

COPY --from=build /app/client/dist ../client/dist

ENV COMMIT_SHA=${COMMIT_SHA} \
COMMIT_BRANCH=${COMMIT_BRANCH} \
COMMIT_TAG=${COMMIT_TAG} \
COMMIT_DESCRIBE=${COMMIT_DESCRIBE}

EXPOSE 8086

CMD ["node", "index.js"]
16 changes: 15 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ const CPAT = {
Env: {
version: "${config.version}",
apiBase: "${config.client.apiBase}",
commit: {
branch: "${config.commit.branch}",
sha: "${config.commit.sha}",
tag: "${config.commit.tag}",
describe: "${config.commit.describe}"
},
oauth: {
authority: "${config.client.authority}",
clientId: "${config.client.clientId}",
Expand All @@ -209,11 +215,19 @@ const CPAT = {
privileges: "${config.oauth.claims.privileges}",
email: "${config.oauth.claims.email}"
}
},
stigman: {
clientId: "${config.stigman.clientId}",
host: "${config.stigman.host}",
port: "${config.stigman.port}",
apiBase: "${config.stigman.apiBase}",
scopePrefix: "${config.stigman.scopePrefix ?? ''}",
extraScopes: "${config.stigman.extraScopes ?? ''}",
}
}
}
`
app.get('/js/Env.js', function (req, res) {
app.get('/cpat/Env.js', function (req, res) {
req.component = 'static'
writer.writeWithContentType(res, { payload: envJS, contentType: "application/javascript" })
})
Expand Down
8 changes: 4 additions & 4 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cpat-api",
"version": "0.2.0",
"description": "Poam tracking tool initial test",
"description": "C-PAT API",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -23,7 +23,7 @@
"jwks-rsa": "^3.1.0",
"lodash": "^4.17.21",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.9.7",
"mysql2": "^3.9.9",
"npm-check-updates": "^16.14.20",
"on-finished": "^2.4.1",
"on-headers": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion api/specification/C-PAT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ info:
contact:
name: Christian Rodriguez
email: christian.a.rodriguez8.ctr@us.navy.mil
version: '1.1'
version: '0.2'
servers:
- url: 'http://localhost:8086/api'
paths:
Expand Down
27 changes: 20 additions & 7 deletions api/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,42 @@ const package = require("../package.json")

let config = {
version: package.version,
commit: {
branch: process.env.COMMIT_BRANCH || 'na',
sha: process.env.COMMIT_SHA || 'na',
tag: process.env.COMMIT_TAG || 'na',
describe: process.env.COMMIT_DESCRIBE || 'na'
},
settings: {
setClassification: process.env.CPAT_CLASSIFICATION || "U",
responseValidation: process.env.CPAT_DEV_RESPONSE_VALIDATION || "none"

},
client: {
clientId: process.env.CPAT_CLIENT_ID || "c-pat",
authority: process.env.CPAT_CLIENT_OIDC_PROVIDER || process.env.CPAT_OIDC_PROVIDER || "http://localhost:2020/auth/realms/RMFTools",
apiBase: process.env.CPAT_CLIENT_API_BASE || "api",
disabled: process.env.CPAT_CLIENT_DISABLED === "true",
directory: process.env.CPAT_CLIENT_DIRECTORY || '../../../client/dist',
directory: process.env.CPAT_CLIENT_DIRECTORY || '../client/dist',
extraScopes: process.env.CPAT_CLIENT_EXTRA_SCOPES,
scopePrefix: process.env.CPAT_CLIENT_SCOPE_PREFIX,
refreshToken: {
disabled: process.env.CPAT_CLIENT_REFRESH_DISABLED ? process.env.CPAT_CLIENT_REFRESH_DISABLED === "true" : false,
},
},
stigman: {
clientId: process.env.STIGMAN_CLIENT_ID || "stig-manager",
host: process.env.STIGMAN_HOST || "localhost",
port: process.env.STIGMAN_PORT || "54000",
apiBase: process.env.STIGMAN_API_BASE || "api",
scopePrefix: process.env.STIGMAN_SCOPE_PREFIX,
extraScopes: process.env.STIGMAN_EXTRA_SCOPES,
},
docs: {
disabled: process.env.CPAT_DOCS_DISABLED === "true",
docsDirectory: process.env.CPAT_DOCS_DIRECTORY || '../../docs/_build/html',
docsDirectory: process.env.CPAT_DOCS_DIRECTORY || '../docs/_build/html',
},
http: {
address: process.env.CPAT_API_ADDRESS || "localhost",
address: process.env.CPAT_API_ADDRESS || "0.0.0.0",
port: process.env.CPAT_API_PORT || 8086,
maxJsonBody: process.env.CPAT_API_MAX_JSON_BODY || "31457280",
maxUpload: process.env.CPAT_API_MAX_UPLOAD || "1073741824"
Expand All @@ -48,7 +61,7 @@ let config = {
port: process.env.CPAT_DB_PORT || 3306,
schema: process.env.CPAT_DB_SCHEMA || "cpat",
password: process.env.CPAT_DB_PASSWORD,
username: process.env.CPAT_DB_USER || "root",
username: process.env.CPAT_DB_USER,
maxConnections: process.env.CPAT_DB_MAX_CONNECTIONS || 25,
minConnections: process.env.CPAT_DB_MIN_CONNECTIONS || 0,
tls: {
Expand All @@ -73,8 +86,8 @@ let config = {
authority: process.env.CPAT_OIDC_PROVIDER || process.env.CPAT_API_AUTHORITY || "http://localhost:2020/auth/realms/RMFTools",
claims: {
scope: process.env.CPAT_JWT_SCOPE_CLAIM || "scope",
username: process.env.CPAT_JWT_USERNAME_CLAIM,
servicename: process.env.CPAT_JWT_SERVICENAME_CLAIM,
username: process.env.CPAT_JWT_USERNAME_CLAIM || "preferred_username",
servicename: process.env.CPAT_JWT_SERVICENAME_CLAIM || "clientId",
fullname: process.env.CPAT_JWT_FULL_NAME_CLAIM || process.env.CPAT_JWT_USERNAME_CLAIM || "name",
firstname: process.env.CPAT_JWT_FIRST_NAME_CLAIM || "given_name",
lastname: process.env.CPAT_JWT_LAST_NAME_CLAIM || "family_name",
Expand Down
31 changes: 0 additions & 31 deletions client/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
"maximumError": "16kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
Expand Down Expand Up @@ -111,31 +105,6 @@
"browserTarget": "cpat:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"node_modules/@nebular/theme/styles/prebuilt/default.css",
"node_modules/bootstrap/dist/css/bootstrap.css",
"src/app/theme/styles/themes.scss",
"src/app/theme/styles/styles.scss",
"node_modules/pace-js/templates/pace-theme-flash.tmpl.css",
"node_modules/font-awesome/scss/font-awesome.scss"
],
"scripts": [
"node_modules/pace-js/pace.min.js"
]
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
Expand Down
Loading

0 comments on commit 6185afa

Please sign in to comment.