Giter Club home page Giter Club logo

static-code-analysis-cicd's Introduction

static-code-analysis-cicd

Example of integrating static code analysis into a CI/CD pipeline. The project includes a sample client and server web application in the src/ directory written in ES6 JavaScript. For demonstration purposes, the static analysis tool used is ESLint. Use of other static analyis tools and/or other programming languages would follow a similar pattern.

The CI/CD pipeline chosen for demonstration purposes is a three-stage continuous deployment pipeline in AWS CodePipeline. The continuous deployment pipeline stages are:

  1. Amazon S3 source
  2. AWS CodeBuild build
  3. AWS CodeDeploy EC2 deployment

The source code initially has a security vulnerability that can be detected by using ESLint. The final environment is as follows:

Final Environment

Getting Started

Deploy the CloudFormation infrastructure/cloudformation.json template. The template creates a user with the following credentials and minimal required permisisons to complete the Lab:

  • Username: student
  • Password: password

Instructions

  1. In the Cloud9 environment, clone the repo with git clone https://github.com/lrakai/static-code-analysis-cicd.git
  2. Install ESLint npm install [email protected] --save-dev
  3. Configure ESLint to use the Standard popular sytle guide eslint --init
  4. Add a validate script to package.json: "validate": "./node_modules/.bin/eslint server/ client/"
  5. Include the validation during the build stage by adding the following command to the build object in buildspec.yml: - npm run validate
  6. Package the source with bash package.sh
  7. Upload the source package to the codeartifacts S3 bucket
  8. Watch the CodePipeline pipeline fail the build stage because of ESLint errors
  9. Fix the error and upload a new version of the source to deploy

Cleaning Up

Delete the CloudFormation stack to remove all the resources used in the Lab.

static-code-analysis-cicd's People

Contributors

lrakai avatar

Watchers

James Cloos avatar  avatar  avatar

static-code-analysis-cicd's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.