Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Feature/elasticsearch authentication #164

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c9df792
Updating the elasticsearch rest client to version 7.6.2
rseedorff Apr 16, 2020
260cbf6
Added new configuration properties needed for the elastic search auth…
rseedorff Apr 16, 2020
48607b5
Implemented two authentication methods for elasticsearch
rseedorff Apr 16, 2020
b7d3c04
Added comments
rseedorff Apr 16, 2020
f6517ba
Fixing some imports
rseedorff Apr 16, 2020
bfb0248
Adding some more log statements
rseedorff Apr 17, 2020
0274e20
Added some application properties defaults for the new authentication…
rseedorff Apr 17, 2020
876f8c9
Added a more detailed documentation to our readme regarding persisten…
rseedorff Apr 17, 2020
f98c4df
Fixing table padding issue
rseedorff Apr 17, 2020
8797ce2
Fixing documentation links
rseedorff Apr 17, 2020
350648a
Fixing table padding issue
rseedorff Apr 17, 2020
fcf962f
Updated camunda dependencies to version 7.12 (WIP)
rseedorff Apr 17, 2020
be23b71
Updated third party dependencies
rseedorff Apr 17, 2020
ac8bd28
Added maven central explicitly due to travis build errors
rseedorff Apr 17, 2020
2229dd9
Bugfixing wrong Url
rseedorff Apr 17, 2020
0840c82
Fixed all ui form issues with new angularjs version
rseedorff Apr 17, 2020
8d37b4f
Fixed UI error with wrong hidden class
rseedorff Apr 17, 2020
88fe486
Removed maven central repo again
rseedorff Apr 17, 2020
37be522
Trying to extend the travis timeout because it fails after 10min (htt…
rseedorff Apr 17, 2020
d0e9943
Removed dependency check (we also have snyk in place) due to travis c…
rseedorff Apr 17, 2020
c3f6636
Fixing coding style issues
rseedorff Apr 17, 2020
fa9c7cc
Updated dependency
rseedorff Apr 18, 2020
058de94
Added a new configuration parameter to enable/disable the kibana dash…
rseedorff Apr 18, 2020
3c00982
Merge pull request #167 from secureCodeBox/feature/updade-camunda-v.7.12
J12934 Apr 20, 2020
a8e2f03
fix: upgrade com.amazonaws:aws-java-sdk-s3 from 1.11.728 to 1.11.754
snyk-bot Apr 20, 2020
3c38a1e
Merge pull request #171 from secureCodeBox/snyk-upgrade-b46c28870f720…
J12934 Apr 21, 2020
47e81b6
Updating the elasticsearch rest client to version 7.6.2
rseedorff Apr 16, 2020
32f60d9
Added new configuration properties needed for the elastic search auth…
rseedorff Apr 16, 2020
4c6277c
Implemented two authentication methods for elasticsearch
rseedorff Apr 16, 2020
221af59
Added comments
rseedorff Apr 16, 2020
e3ba3c0
Fixing some imports
rseedorff Apr 16, 2020
6f609e7
Adding some more log statements
rseedorff Apr 17, 2020
571e917
Added some application properties defaults for the new authentication…
rseedorff Apr 17, 2020
703da59
Added a more detailed documentation to our readme regarding persisten…
rseedorff Apr 17, 2020
b00762e
Fixing table padding issue
rseedorff Apr 17, 2020
f980914
Fixing documentation links
rseedorff Apr 17, 2020
c18b91f
Fixing table padding issue
rseedorff Apr 17, 2020
f428a45
Added a new configuration parameter to enable/disable the kibana dash…
rseedorff Apr 18, 2020
4cafe61
Merge branch 'feature/elastic-authentication' of github.com:secureCod…
rseedorff Apr 22, 2020
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
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ cache:
install: true
script:
- set -e
- echo -en "travis_fold:start:Test\r"
- mvn install -Pdependency-check -B
- echo -en "travis_fold:end:Test\r"
- export REPO=securecodebox/engine
- export TAG=$(echo $TRAVIS_BRANCH | sed 's/\//-/g')
- echo -en "travis_fold:start:Docker_Build\r"
Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,51 @@ This allows you to e.g. enable https using:
| SERVER_SSL_ENABLED | Enables http over ssl | true |
| SERVER_SSL_KEY_STORE_PASSWORD | Password to the java keystore | AStrongPassword-NotThisOne! |

## Persistence Provider Configuration
A more detailed description of all persistence specific integration configuration options can be fund here: [secureCodeBox Integration Documentation][scb-integration]

### Enabling Elasticsearch as Persistence Provider
All properties defined in scb-engine/src/main/resources/application.yaml can be overwritten via environment variables.

| Property | Example Value |
| ---------------------------------------------------- | -------------------------- |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_ENABLED | true |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_HOST | elasticsearch.example.com |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_PORT | 9200 |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_INDEX_PREFIX | securecodebox |

### Configure Elasticsearch Basic Authentication
If your elasticsearch service enforces authentication your can configure basic authentication:

| Property | Example Value |
| ----------------------------------------------------------- | --------------------------- |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_AUTH | basic |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_AUTH_BASIC_USERNAME | elastic |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_AUTH_BASIC_PASSWORD | AStrongPassword-NotThisOne! |

### Configure Elasticsearch API Token Authentication
If your elasticsearch service enforces authentication your can configure api token based authentication:

| Property | Example Value |
| ----------------------------------------------------------- | --------------------------- |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_AUTH | token |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_AUTH_APIKEY_ID | yourToken |
| SECURECODEBOX_PERSISTENCE_ELASTICSEARCH_AUTH_APIKEY_SECRET | 7fd7eac6fed567b19932492347 |

### Enabling DefectDojo as Persistence Provider
All properties defined in scb-engine/src/main/resources/application.yaml can be overwritten via environment variables.

#### Properties / Environment Variables

| Property | Example Value |
| ---------------------------------------------- | ---------------------------------------- |
| SECURECODEBOX_PERSISTENCE_DEFECTDOJO_ENABLED | true |
| SECURECODEBOX_PERSISTENCE_DEFECTDOJO_URL | [http://localhost:8000]() |
| SECURECODEBOX_PERSISTENCE_DEFECTDOJO_AUTH_KEY | 7fd7eac6fed567b19928f7928a7ddb86f0497e4e |
| SECURECODEBOX_PERSISTENCE_DEFECTDOJO_AUTH_NAME | admin |

Alternatively the corresponding environment variables, e.g. `SECURECODEBOX_PERSISTENCE_DEFECTDOJO_URL` can be used.

# Development

## Local setup
Expand Down Expand Up @@ -78,4 +123,5 @@ Well boring yes - but please read our [guidelines and naming standards][scb-deve

[docker]: https://www.docker.com/
[beta-testers]: https://www.securecodebox.io/
[scb-integration]: https://www.securecodebox.io/integrations
[owasp]: https://www.owasp.org/index.php/Main_Page
23 changes: 12 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
IMPORTANT: camunda.version and camunda.spring.boot.starter.version must be compatible
please see org.camunda.bpm.springboot.project:camunda-bpm-spring-boot-starter-root
-->
<camunda.version>7.10.0</camunda.version>
<camunda.spring.boot.starter.version>3.2.8</camunda.spring.boot.starter.version>
<camunda.version>7.12.0</camunda.version>
<camunda.spring.boot.starter.version>3.4.2</camunda.spring.boot.starter.version>
<!-- END IMPORTANT -->

<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
<spring-boot.version>2.2.6.RELEASE</spring-boot.version>
<swagger-version>2.9.2</swagger-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down Expand Up @@ -101,6 +101,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<version>${spring-boot.version}</version>
<scope>runtime</scope>
</dependency>

Expand Down Expand Up @@ -144,7 +145,7 @@
<groupId>org.camunda.bpm.extension.mockito</groupId>
<artifactId>camunda-bpm-mockito</artifactId>
<scope>test</scope>
<version>3.2.1</version>
<version>4.12.0</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
Expand All @@ -155,7 +156,7 @@
<dependency>
<groupId>org.camunda.bpm.extension</groupId>
<artifactId>camunda-bpm-assert-scenario</artifactId>
<version>0.2</version>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -203,7 +204,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -217,12 +218,12 @@
<pluginRepository>
<id>jcenter-snapshots</id>
<name>jcenter</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
<url>https://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
</pluginRepository>
<pluginRepository>
<id>jcenter-releases</id>
<name>jcenter</name>
<url>http://jcenter.bintray.com</url>
<url>https://jcenter.bintray.com</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
Expand Down Expand Up @@ -256,7 +257,7 @@
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>5.2.4</version>
<version>5.3.2</version>
<configuration>
<format>ALL</format>
<suppressionFile>dependency-check-suppression.xml</suppressionFile>
Expand Down Expand Up @@ -315,7 +316,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.2.1</version>
<executions>
<execution>
<id>generate-sources</id>
Expand All @@ -328,7 +329,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<version>3.2.0</version>
<executions>
<execution>
<id>generate-javadocs</id>
Expand Down
19 changes: 1 addition & 18 deletions scb-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
<version>2.2.2.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.2.2.RELEASE</version>
<version>5.3.1.RELEASE</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -90,22 +89,6 @@
<artifactId>tomcat-jdbc</artifactId>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>9.0.31</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<version>9.0.31</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>9.0.31</version>
</dependency>

<dependency>
<groupId>io.securecodebox.persistenceproviders</groupId>
<artifactId>empty-persistenceprovider</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions scb-engine/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ securecodebox.persistence.elasticsearch.host: persistence-elasticsearch
securecodebox.persistence.elasticsearch.port: 9200
securecodebox.persistence.elasticsearch.index.prefix: securecodebox
securecodebox.persistence.elasticsearch.index.delete_on_init: false
# Must be 'basic' for basic authentication or 'token' for a api token based authentication
securecodebox.persistence.elasticsearch.auth: ""
securecodebox.persistence.elasticsearch.auth.basic.username: ""
securecodebox.persistence.elasticsearch.auth.basic.password: ""
securecodebox.persistence.elasticsearch.auth.apikey.id: ""
securecodebox.persistence.elasticsearch.auth.apikey.secret: ""

# Initialize Kibana with some basic Security Dashboards and Visualisations if no .kibana index will be found on startup
securecodebox.persistence.elasticsearch.kibana.initialize: true


securecodebox.default.target.name: BodgeIT Public Host
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.*;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.ResourceHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
Expand Down Expand Up @@ -206,7 +211,7 @@ public EngagementResponse createEngagement(EngagementPayload engagementPayload)
public ImportScanResponse createFindings(String rawResult, long engagementId, long lead, String currentDate, String defectDojoScanName) {
return createFindings(rawResult, engagementId, lead, currentDate,defectDojoScanName, "", new LinkedMultiValueMap<>());
}
/**
/*
* Before version 1.5.4. testName (in DefectDojo _test_type_) must be defectDojoScanName, afterwards, you can have somethings else
*/
public ImportScanResponse createFindings(String rawResult, long engagementId, long lead, String currentDate,String defectDojoScanName, String testName, MultiValueMap<String, Object> options) {
Expand Down Expand Up @@ -254,7 +259,7 @@ public String getFilename() {
throw new DefectDojoPersistenceException("Failed to attach findings to engagement.");
}
}
/**
/*
* When DefectDojo >= 1.5.4 is used, testType can be given. Add testName in case DefectDojo >= 1.5.4 is used
* Using testName for each branch leads to multiple issues in DefectDojo, so it is not recommended
*/
Expand Down Expand Up @@ -363,7 +368,7 @@ private long getTestIdOrCreate(long engagementId, TestPayload testPayload, Strin
return testId.longValue();
}

/**
/*
* @deprecated
*/
public ImportScanResponse createFindingsReImport(String rawResult, String productName, String engagementName, long lead, String currentDate, String defectDojoScanName, EngagementPayload engagementPayload, TestPayload testPayload, MultiValueMap<String, Object> options) {
Expand Down Expand Up @@ -480,7 +485,7 @@ private Optional<Long> getEngagementIdByEngagementName(String engagementName, lo
LOG.warn("Engagement with name '{}' not found.", engagementName);
return Optional.empty();
}
/**
/*
* @deprecated
*/
public ProductResponse createProduct(String productName) {
Expand Down Expand Up @@ -508,7 +513,9 @@ public void deleteUnusedBranches(List<String> existingBranches, String producNam

/**
* Deletes engagements based on branch tag
* Be aware that the branch tag MUST be set, otherwise all engagments will be deleted
* Be aware that the branch tag MUST be set, otherwise all engagements will be deleted
* @param existingBranches The list of existing branches
* @param productId The productId to find engagements for
*/
public void deleteUnusedBranches(List<String> existingBranches, long productId) {
if(existingBranches == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<version>0.0.1-SNAPSHOT</version>

<properties>
<elasticsearch.version>6.8.7</elasticsearch.version>
<elasticsearch.version>7.6.2</elasticsearch.version>
</properties>


Expand All @@ -53,6 +53,18 @@
<version>${elasticsearch.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>${elasticsearch.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
Expand Down
Loading