From 39f128cffcbb09e6311fb87624e575529746d55d Mon Sep 17 00:00:00 2001 From: David Adewole Date: Fri, 25 Jun 2021 21:40:24 +0100 Subject: [PATCH] application-scanner-task --- accounts/.env | 4 ++-- accounts/src/config.js | 2 +- application-scanner/Dockerfile | 20 +------------------- application-scanner/Dockerfile.dev | 26 ++++++++++++++++++++++++++ application-scanner/index.js | 4 ++-- backend/.env | 4 ++-- docker-compose.dev.yml | 21 ++++++++++++++++++++- docker-compose.yml | 14 ++++++++++++++ 8 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 application-scanner/Dockerfile.dev diff --git a/accounts/.env b/accounts/.env index 039551cc8b..4fe4557e50 100644 --- a/accounts/.env +++ b/accounts/.env @@ -4,6 +4,6 @@ STRIPE_PUBLIC_KEY=pk_test_UynUDrFmbBmFVgJXd9EZCvBj00QAVpdwPv AMPLITUDE_PUBLIC_KEY=cb70632f45c1ca7fe6180812c0d6494a SKIP_PREFLIGHT_CHECK=true PUBLIC_URL=/accounts -REACT_APP_IS_SAAS_SERVICE=true -IS_SAAS_SERVICE=true +#REACT_APP_IS_SAAS_SERVICE=true +#IS_SAAS_SERVICE=true #REACT_APP_DISABLE_SIGNUP=true diff --git a/accounts/src/config.js b/accounts/src/config.js index 28355bdcd4..265e188518 100755 --- a/accounts/src/config.js +++ b/accounts/src/config.js @@ -175,7 +175,7 @@ export const Validate = { return false; }, - isValidBusinessEmail() { + isValidBusinessEmail(email) { // return emaildomains.test(email); return true; }, diff --git a/application-scanner/Dockerfile b/application-scanner/Dockerfile index d51110072f..6648cec1ea 100755 --- a/application-scanner/Dockerfile +++ b/application-scanner/Dockerfile @@ -7,29 +7,11 @@ FROM node:16 #SET ENV Variables ENV PRODUCTION=true -#ENV CHROME_PATH=/usr/bin/google-chrome - -# Install Chrome. -# RUN \ -# wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ -# echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ -# apt-get update && \ -# apt-get install -y google-chrome-stable && \ -# rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -# Install trivy for container scanning -RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sh -s -- -b /usr/local/bin - -# Install kubectl for kubernetes monitor scanning -RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" -RUN chmod +x ./kubectl -RUN mv ./kubectl /usr/local/bin/kubectl && \ - chown root: /usr/local/bin/kubectl - # Install app dependencies COPY package*.json /usr/src/app/ RUN npm ci --only=production @@ -39,7 +21,7 @@ COPY . /usr/src/app # Expose ports. # - 3004: Application Scanner -EXPOSE 3004 +EXPOSE 3005 #Run the app CMD [ "npm", "start"] diff --git a/application-scanner/Dockerfile.dev b/application-scanner/Dockerfile.dev new file mode 100644 index 0000000000..0fdbd4085a --- /dev/null +++ b/application-scanner/Dockerfile.dev @@ -0,0 +1,26 @@ +# +# Fyipe-backend Dockerfile +# + +# Pull base image nodejs image. +FROM node:16 + +WORKDIR /usr/src/app + +# Install app dependencies +RUN cd /usr/src/app + +# Copy package.json files +COPY ./package.json /usr/src/app/package.json +COPY ./package-lock.json /usr/src/app/package-lock.json + + +RUN npm ci + +# Expose ports. +# - 3004: Application Scanner +EXPOSE 3005 + +#Run the app +CMD [ "npm", "run", "dev"] + diff --git a/application-scanner/index.js b/application-scanner/index.js index 9cc6428c5a..e28990e01d 100644 --- a/application-scanner/index.js +++ b/application-scanner/index.js @@ -35,7 +35,7 @@ const config = require('./utils/config'); const cronApplicationSecurityStartTime = Math.floor(Math.random() * 50); app.use(cors()); -app.set('port', process.env.PORT || 3004); +app.set('port', process.env.PORT || 3005); http.listen(app.get('port'), function() { // eslint-disable-next-line @@ -66,7 +66,7 @@ app.get(['/application/version', '/version'], function(req, res) { }); // Run this cron at 3 AM once a day. -cron.schedule('*/2 * * * *', () => { +cron.schedule('0 3 * * *', () => { setTimeout(() => { Main.runApplicationScan(); }, cronApplicationSecurityStartTime * 1000); diff --git a/backend/.env b/backend/.env index 98bf2af9d4..a122436eff 100755 --- a/backend/.env +++ b/backend/.env @@ -10,9 +10,9 @@ MONGO_URL=mongodb://localhost:27017/fyipedb REDIS_HOST=localhost CLUSTER_KEY=f414c23b4cdf4e84a6a66ecfd528eff2 TEST_TWILIO_NUMBER=+919910568840 -IS_SAAS_SERVICE=true +#IS_SAAS_SERVICE=true ENCRYPTION_KEY=01234567890123456789012345678901 -IS_TESTING=true +#IS_TESTING=true PUSHNOTIFICATION_PRIVATE_KEY=8aXTsH48-cegK-xBApLxxOezCOZIjaWpg81Dny2zbio PUSHNOTIFICATION_PUBLIC_KEY=BFAPbOTTU14VbTe_dnoYlVnOPLKUNm8GYmC50n3i4Ps64sk1Xqx8e894Clrscn1L2PsQ8-l4SsJVw7NRg4cx69Y PUSHNOTIFICATION_URL=mailto:support@fyipe.com diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 0c73e14ae2..f6662e4365 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -261,6 +261,25 @@ services: # Use node modules of the container and not host system. # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder - /usr/src/app/node_modules/ - + application-scanner: + ports: + - '3005:3005' + - '9240:9229' # Debugging port. + build: + context: ./application-scanner + dockerfile: ./Dockerfile.dev + env_file: + - ./application-scanner/.env + environment: + - PORT=3005 + - SERVER_URL=http://backend:3002 + - APPLICATION_SCANNER_NAME=US + - APPPLICATION_SCANNER_KEY=test-key + - IS_SAAS_SERVICE=${IS_SAAS_SERVICE} + volumes: + - ./application-scanner:/usr/src/app + # Use node modules of the container and not host system. + # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder + - /usr/src/app/node_modules/ volumes: mongodata: diff --git a/docker-compose.yml b/docker-compose.yml index 6b0a177327..df56b2cf44 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -180,6 +180,20 @@ services: build: ./script-runner environment: - IS_SAAS_SERVICE=${IS_SAAS_SERVICE} + application-scanner: + ports: + - '3005:3005' + build: ./application-scanner + env_file: + - ./application-scanner/.env + environment: + - PORT=3005 + - SERVER_URL=http://backend:3002 + - APPLICATION_SCANNER_NAME=US + - APPLICATION_SCANNER_KEY=test-key + - IS_SAAS_SERVICE=${IS_SAAS_SERVICE} + depends_on: + - backend volumes: mongodata: