Coder Social home page Coder Social logo

softrams / bulwark Goto Github PK

View Code? Open in Web Editor NEW
180.0 10.0 37.0 47.63 MB

An organizational asset and vulnerability management tool, with Jira integration, designed for generating application security reports.

License: MIT License

JavaScript 0.72% TypeScript 83.88% HTML 14.18% Sass 0.18% SCSS 0.29% Dockerfile 0.75% Shell 0.01%
security-tools vulnerability-management angular typeorm typescript nodejs express webappsec appsec application-security vulnerability-report pentesting vulnerability-assessment security-tool penetration-testing-tools vulnerability-research bugbounty blue-team red-team

bulwark's Introduction

An organizational asset and vulnerability management tool, with Jira integration, designed for generating application security reports.

Features

  • Multi-client Vulnerability Management
  • Security Report Generation
  • Jira Integration
  • Team-based Roles Authorization
  • API Key & Management
  • Email Integration
  • Markdown Support

Note

Please keep in mind, this project is in early development.

Demo

Bulwark Walkthrough Demo

Jira Integration

Bulwark Jira Demo

Launch with Docker

  1. Install Docker
  2. Create a .env file and supply the following properties:
MYSQL_DATABASE="bulwark"
MYSQL_PASSWORD="bulwark"
MYSQL_ROOT_PASSWORD="bulwark"
MYSQL_USER="root"
MYSQL_DB_CHECK="mysql"
DB_PASSWORD="bulwark"
DB_URL="172.16.16.3"
DB_ROOT="root"
DB_USERNAME="bulwark"
DB_PORT=3306
DB_NAME="bulwark"
DB_TYPE="mysql"
NODE_ENV="production"
DEV_URL="http://localhost:4200"
SERVER_ADDRESS="http://localhost"
PORT=4500
JWT_KEY="changeme"
JWT_REFRESH_KEY="changeme"
CRYPTO_SECRET="changeme"
CRYPTO_SALT="changeme"

Build and start Bulwark containers:

docker-compose up

Start/Stop Bulwark containers:

docker-compose start
docker-compose stop

Remove Bulwark containers:

docker-compose down

Bulwark will be available at localhost:4500

Local Installation

$ git clone (url)
$ cd bulwark
$ npm install

Running npm install will install both server-side and client-side modules. Furthermore, it will run the script npm run config which will dynamically set the environment variables in addition to updating the Angular environment.

Development Mode

Set NODE_ENV="development"

$ npm run config
$ npm run start:dev

Production Mode

Set NODE_ENV="production" Please note: npm install will automatically build in production mode

$ npm run config
$ npm run build:prod
$ npm start

Environment variables

Create a .env file on the root directory. This will be parsed with dotenv by the application.

DB_PASSWORD

DB_PASSWORD="somePassword"

Set this variable to database password

DB_USERNAME

DB_USERNAME="foobar"

Set this variable to database user name

DB_URL

DB_URL=something-foo-bar.dbnet

Set this variable to database URL

DB_PORT

DB_PORT=3306

Set this variable to database port

DB_NAME

DB_NAME="foobar"

Set this variable to database connection name

DB_TYPE

DB_TYPE="mysql"

The application was developed using a MySQL database. See the typeorm documentation for more database options.

NODE_ENV

NODE_ENV=production

Set this variable to determine node environment

DEV_URL="http://localhost:4200"

Used by Angular to build and serve the application

SERVER_ADDRESS="http://localhost"

Update if a different server address is required

PORT=4500

Update if a different server port is required

JWT_KEY

JWT_KEY="changeMe"

Set this variable to the JWT secret

JWT_REFRESH_KEY

JWT_REFRESH_KEY="changeMe"

Set this variable to the refresh JWT secret

CRYPTO_SECRET

CRYPTO_SECRET="randomValue"

Set this variable to the Scrypt password.

CRYPTO_SALT

CRYPTO_SECRET="randomValue"

Set this variable to the Scrypt salt.

Empty .env file template

DB_PASSWORD=""
DB_URL=""
DB_USERNAME=""
DB_PORT=3306
DB_NAME=""
DB_TYPE=""
NODE_ENV=""
DEV_URL="http://localhost:4200"
SERVER_ADDRESS="http://localhost"
PORT=4500
JWT_KEY=""
JWT_REFRESH_KEY=""
CRYPTO_SECRET=""
CRYPTO_SALT=""

Note on M1/M2 Macs

Install sqlite3: 
brew install sqlite3

Export compiler related env variables: 
export LDFLAGS="-L/opt/homebrew/opt/sqlite/lib"
export CPPFLAGS="-I/opt/homebrew/opt/sqlite/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig"
export NODE_OPTIONS=--openssl-legacy-provider

Prepare for a fresh install:
rm -rf node_modules
npm cache verify
npm i --force

### Create Initial Database Migration

1. Create the initial database migration

$ npm run migration:init


2. Run the initial database migration

$ npm run migration:run


## Default credentials

A user account is created on initial startup with the following credentials:

- email: `[email protected]`
- password: `changeMe`

Upon first login, update the default user password under the profile section.

## Roles

The application utilizes least privilege access with team-based authorization. Teams are assigned a role which determines the features available to that specific team. A user will inherit roles from team membership. Administrators have team management access and must assign users to teams. Initially, users are created with no team association and will not have access to any features in the application.

The three roles include:

1. Admin
2. Tester
3. Read-Only

A team can only be associated to a single organization. However, a team can be associated to multiple assets within the same organization. A user can be a member of multiple teams. If a user is assigned to multiple teams of the same organization, the system will choose the highest authorized team.

_Please note: The default user is automatically assigned to the `Administrators` team on initial startup_

### Role Matrix

<table>
  <tr>
    <td></td>
    <th scope="col">Admin</th>
    <th scope="col">Tester</th>
    <th scope="col">Read-Only</th>
  </tr>
  <tr>
    <th scope="row">User-Profile Management</th>
    <td>x</td>
    <td>x</td>
    <td>x</td>
  </tr>
  <tr>
    <th scope="row">Team Management</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">User Management</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Invite User</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Create User</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Email Settings Management</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Jira Integration</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Organization: Read</th>
    <td>x</td>
    <td>x</td>
    <td>x</td>
  </tr> 
  <tr>
    <th scope="row">Organization: Full Write</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Asset: Read</th>
    <td>x</td>
    <td>x</td>
    <td>x</td>
  </tr> 
  <tr>
    <th scope="row">Asset: Full Write</th>
    <td>x</td>
    <td></td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Assessment: Read</th>
    <td>x</td>
    <td>x</td>
    <td>x</td>
  </tr> 
  <tr>
    <th scope="row">Assessment: Full Write</th>
    <td>x</td>
    <td>x</td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Vulnerability: Read</th>
    <td>x</td>
    <td>x</td>
    <td>x</td>
  </tr> 
  <tr>
    <th scope="row">Vulnerability: Full Write</th>
    <td>x</td>
    <td>x</td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Export Vulnerability to Jira</th>
    <td>x</td>
    <td>x</td>
    <td></td>
  </tr> 
  <tr>
    <th scope="row">Report Generation</th>
    <td>x</td>
    <td>x</td>
    <td>x</td>
  </tr> 
</table>

<br>

## API Key & Management

A user may generate a single API key which can be used in place of their authorization token. This API key allows for all actions against the application that the user is authorized for.

### Generating an API key pair

1. Login to the application
2. Navigate to the `User Profile` section
3. Select `Generate API Key`

This action will generate a pair of keys:

1. `Bulwark-Api-Key`
   1. This is a generated plaintext value to identify the user.
2. `Bulwark-Secret-Key`
   1. This is a generated plaintext value to verify the user by comparing a [Bcrypt](https://www.npmjs.com/package/bcrypt) hash stored in the database.

<strong>Write down the generated keys in a safe place. You will not be able to retrieve the keys at a later time.</strong>

### How to use API keys

The API key pair values must be matched and appended to the following HTTP request headers:

- `Bulwark-Api-Key`
- `Bulwark-Secret-Key`

Example:

GET /api/assessment/1 HTTP/1.1 Host: localhost:4500 Accept: application/json, text/plain, / Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Bulwark-Api-Key: {{changeMe}} Bulwark-Secret-Key: {{changeMe}} Origin: http://localhost:4200 Connection: close Referer: http://localhost:4200/ Pragma: no-cache Cache-Control: no-cache


## Built With

- [Typeorm](https://typeorm.io/#/) - The ORM used
- [Angular](https://angular.io/) - The Angular Framework
- [Express](https://expressjs.com/) - A minimal and flexible Node.js web application framework

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Read the [contribution guidelines](CONTRIBUTING.md) for more information.

## License

[MIT](https://choosealicense.com/licenses/mit/)

bulwark's People

Contributors

alejandrosaenz117 avatar bmayen avatar bmayen-sr avatar darrellrichards avatar dependabot[bot] avatar joshuaseidel avatar markmuth avatar mkmurali avatar nopr9d avatar noprod avatar noraj avatar skewled avatar waterweasel4 avatar whamo12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bulwark's Issues

Unit Test: AppComponent

Following the Angular testing guidelines, implement unit tests for the AppComponent.

At least 80% code coverage is required.

Cannot Login due to User updates

A user cannot login due to the User updates with the inclusion of firstName, lastName, and title columns.

Existing users will manually have to be updated via the database.

The register component has been updated to include these fields.

Create user profile angular component

As a user, I want to update my profile so that I can update my email address and password.

Acceptance criteria

  • Add a new link to the navbar menu option called Profile
  • The link should navigate to /user/profile
  • The link should render the new user-profile component
  • The component should contain an input field containing the email of the user
  • The component should contain an input field containing the title of the user
  • The component should contain input fields for user's first name and last name

Goal:
This ticket should encompass creating a scalable API call to update the user's first name, last name, and title. Make sure that the JWT token is utilized to update the user profile to mitigate IDOR. This ticket will not implement the ability to update the user's email address or password.

Ability to update user email

As a user, I should be able to update my email address so that I can update my login information.

Append to the user-profile.component by adding an additional form below the profile information. This will be a single field form that allows the user to update their email address.

Once a user's email has been updated, a confirmation email should be sent to the new email address so that Bulwark can verify the user. If the email is not verified, then the previous email is still active.

Implement Refresh Token

As a system, a refresh token is required so that the user does have to re-authenticate when their JWT token expires.

The current JWT token has an expiration time of 30 minutes which forces the user to re-authenticate. It is frustrating to fill out a vulnerability form only to receive a HTTP 401 message because the token expired.

I prefer to keep the JWT tokens stateless.

Acceptance criteria

  1. Implement a second refresh token which is created on authentication.
  2. The refresh token should have a longer expiry date than the current auth token.
  3. The refresh token should be stored along side the auth token in local storage.
  4. The HTTP interceptor should be modified to handle the expiration of a token.
  5. A refresh API token should be implemented that will seamlessly create new tokens and return to the client
  6. The HTTP interceptor should seamlessly store these tokens in local storage

Make the Application Security Team on the report dynamic

The Application Security Team in the generated report is hardcoded. Now that user information has been implemented, it's time to make the team dynamic. The assessment form will have a new pick-list where the user can choose who the testers will be. These testers will then be listed on the generated report.

Add client's timezone offset to DatePipe

Currently, Angular's DatePipe uses locale to display date in user's timezone. This is causing Angular to display incorrect dates to the user. To fix this, we need to display dates with the client's timezone data offset. Follow the Angular documentation for more information.

Steps to reproduce

  1. Log into the application
  2. Select an Organization
  3. Select an asset
  4. Create an assessment (keep track of the start date and end date selected)
  5. Notice incorrect dates on the Assessment summary table.

Angular Linting Failing

Describe the bug
Angular linting is failing due to object access via string literals is disallowed

Problem Locations

WARNING: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/app.service.spec.ts[9, 41]: get is deprecated: from v9.0.0 use TestBed.inject
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/app.service.ts[34, 9]: Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/app.service.ts[67, 9]: Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
WARNING: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/auth.service.spec.ts[9, 42]: get is deprecated: from v9.0.0 use TestBed.inject
WARNING: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/global-manager.service.spec.ts[9, 51]: get is deprecated: from v9.0.0 use TestBed.inject
WARNING: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/loader.service.spec.ts[9, 44]: get is deprecated: from v9.0.0 use TestBed.inject
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/org-form/org-form.component.ts[32, 27]: object access via string literals is disallowed
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/org-form/org-form.component.ts[33, 54]: object access via string literals is disallowed
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/vuln-form/vuln-form.component.ts[288, 12]: object access via string literals is disallowed
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/vuln-form/vuln-form.component.ts[304, 42]: object access via string literals is disallowed
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/vuln-form/vuln-form.component.ts[304, 50]: object access via string literals is disallowed
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/vuln-form/vuln-form.component.ts[319, 60]: object access via string literals is disallowed
ERROR: /Users/alejandrosaenz/Repositories/bulwark/frontend/src/app/vuln-form/vuln-form.component.ts[342, 84]: object access via string literals is disallowed```

**Steps to Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
Linting rules should pass

Start/End Date

The start/end date is listed as Start Date / Start Date on the assessment form. This should be changed to Start Date / End Date.
Screen Shot 2020-05-13 at 12 42 56 PM

Implement Backend Unit Testing

Currently the back-end code lacks unit testing. This ticket is responsible for setting up the initial unit testing framework and is required before any unit tests are implemented.

Package.json scripts are unable to run on Windows machine

Describe the bug
Any package.json scripts that utilize the ng commands do not work on a windows machine.

Problem Locations

Invalid option for project: '.'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `tslint --project '.' && cd frontend && node ./node_modules/@angular/cli/bin/ng lint`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Expected behavior
Package.json scripts should be OS agnostic.

Update Security Report with 0 findings

When a report with 0 findings is generated, the vulnerability summary table still shows and an additional page is also created. This may be confusing for the reader.

A 0 finding report should replace the vulnerability summary table with a clear an concise message such as "No vulnerabilities were found during this assessment."

Unit Test: AppService

Following the Angular testing guidelines, implement unit tests for the AppService.

At least 80% code coverage is required.

Ability to update user password

As a user, I should be able to update my password so that I can continue to keep my account secure.

A new form should be appended to the user-profile.component that gives the ability to update the user's password. The form should contain three fields:

  1. Current user password
  2. New user password
  3. Confirm new user password

Utilize the updatePassword function in the user.controller.ts file.

Once the password is updated, it'll take effect immediately for the next login.

Menu dropdown margin is out of the page

Describe the bug
Menu drop-down opens outside of window

Steps to Reproduce
Steps to reproduce the behavior:

  1. Log into the application
  2. Click the menu drop-down
  3. Notice drop-down bleeds outside of window

Expected behavior
Adjust menu drop-down so it's within the page window

Screenshots
Capture2

Desktop (please complete the following information):

  • OS: Windows 10
  • Firefox

Unit Test: AlertComponent

Following the Angular testing guidelines, implement unit tests for the AlertComponent.

At least 80% code coverage is required.

Refactor: checkToken

Currently, thecheckToken function can not be tested without loading the env var its test file.

The test should be isolated from using env var. Therefore, the checkToken needs to be updated to add the secret in the formal parameters of the function and consequently passed into the verification.

Implement User Seeding Functionality

Creating the first user is complicated and requires multiple steps. This is confusing for first time users.

I suggest creating a seed-user.js file which will automatically create a user. For example:

node seed-user.js

This file will simply need a configuration object that will automatically be passed into the function. This object will include the user's credentials needed to login. Furthermore, this configuration will be thoroughly documented within the seed-user.js file for easy setup.

This task will also update the README with updated instructions.

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.