├── docker └── README.md ├── .github ├── CODEOWNERS ├── workflows │ ├── maven-pr-checks.yml │ └── maven-snapshot-release.yml ├── stale.yml ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── MAINTAINERS ├── src ├── devops │ ├── keys.gpg.enc │ ├── deploy-snapshot.sh │ ├── release.sh │ ├── .travis.settings.xml │ └── checkstyle-suppressions.xml ├── main │ ├── resources │ │ ├── version.properties │ │ └── logback.xml │ └── java │ │ └── com │ │ └── capitalone │ │ └── dashboard │ │ ├── webhook │ │ ├── github │ │ │ ├── GitHubPayloadType.java │ │ │ ├── GitHubHookService.java │ │ │ ├── GitHubSyncService.java │ │ │ ├── GitHubHookController.java │ │ │ └── GitHubSyncController.java │ │ ├── datasync │ │ │ ├── DataSyncService.java │ │ │ └── DataSyncController.java │ │ ├── sonarqube │ │ │ ├── SonarQubeHookService.java │ │ │ └── SonarCollector.java │ │ └── settings │ │ │ ├── WebHookSettings.java │ │ │ ├── JenkinsBuildWebHookSettings.java │ │ │ └── GitHubWebHookSettings.java │ │ ├── service │ │ ├── BusCompOwnerService.java │ │ ├── MaturityModelService.java │ │ ├── EncryptionService.java │ │ ├── TeamInventoryService.java │ │ ├── CollectorItemService.java │ │ ├── FeatureFlagService.java │ │ ├── LogAnalysisService.java │ │ ├── ConfigurationService.java │ │ ├── InfraStructureService.java │ │ ├── AutoDiscoveryService.java │ │ ├── DashboardRemoteService.java │ │ ├── GenericCollectorItemService.java │ │ ├── ScoreService.java │ │ ├── ServiceAccountService.java │ │ ├── ScoreCriteriaSettingsService.java │ │ ├── CmdbRemoteService.java │ │ ├── PipelineService.java │ │ ├── MetadataService.java │ │ ├── RallyFeatureService.java │ │ ├── PerformanceService.java │ │ ├── BinaryArtifactService.java │ │ ├── UserInfoService.java │ │ ├── CodeQualityService.java │ │ ├── LibraryPolicyService.java │ │ ├── BuildService.java │ │ ├── TestResultService.java │ │ ├── ScoreCriteriaSettingsServiceImpl.java │ │ ├── CommitService.java │ │ ├── ScoreDashboardService.java │ │ ├── TemplateService.java │ │ ├── EncryptionServiceImpl.java │ │ ├── MaturityModelServiceImpl.java │ │ ├── GitRequestService.java │ │ ├── DeployService.java │ │ ├── TeamInventoryServiceImpl.java │ │ ├── CmdbService.java │ │ ├── Monitor2Service.java │ │ ├── TemplateServiceImpl.java │ │ ├── CloudVirtualNetworkService.java │ │ ├── TeamService.java │ │ ├── CloudInstanceService.java │ │ ├── ScopeService.java │ │ ├── AuthenticationService.java │ │ ├── CloudVolumeService.java │ │ ├── InfraStructureServiceImpl.java │ │ ├── CloudSubnetService.java │ │ └── FeatureFlagServiceImpl.java │ │ ├── model │ │ ├── ApiTokenResponse.java │ │ ├── deploy │ │ │ ├── Server.java │ │ │ ├── Environment.java │ │ │ └── DeployableUnit.java │ │ ├── LoginCredentials.java │ │ ├── WidgetResponse.java │ │ ├── TemplateResponse.java │ │ ├── InsertStatus.java │ │ ├── DataResponse.java │ │ ├── PipelineResponseCommit.java │ │ └── monitor │ │ │ ├── MonitorProxySettings.java │ │ │ └── MonitorService.java │ │ ├── auth │ │ ├── sso │ │ │ └── SsoAuthenticationService.java │ │ ├── webhook │ │ │ └── github │ │ │ │ ├── GithubWebHookAuthService.java │ │ │ │ └── GithubWebHookAuthServiceImpl.java │ │ ├── AuthenticationResponseService.java │ │ ├── exceptions │ │ │ ├── DeleteLastAdminException.java │ │ │ └── UserNotFoundException.java │ │ ├── openid │ │ │ └── OpenIdAuthenticationService.java │ │ ├── token │ │ │ └── TokenAuthenticationService.java │ │ ├── ldap │ │ │ ├── LdapAuthenticationDetailsSource.java │ │ │ └── LdapLoginRequestFilter.java │ │ ├── access │ │ │ ├── Admin.java │ │ │ ├── DashboardOwnerOrAdmin.java │ │ │ └── MethodLevelSecurityHandler.java │ │ ├── AuthenticationResultHandler.java │ │ ├── AuthenticationUtil.java │ │ └── standard │ │ │ ├── StandardAuthenticationProvider.java │ │ │ ├── StandardAuthenticationToken.java │ │ │ └── StandardLoginRequestFilter.java │ │ ├── request │ │ ├── EncryptionRequest.java │ │ ├── FeatureFlagRequest.java │ │ ├── CloudRequest.java │ │ ├── DataSyncRequest.java │ │ ├── DashboardRequestTitle.java │ │ ├── LogAnalysisSearchRequest.java │ │ ├── ApiTokenRequest.java │ │ ├── SonarDataSyncRequest.java │ │ ├── ServiceAccountRequest.java │ │ ├── TeamInventoryRequest.java │ │ ├── GitSyncRequest.java │ │ ├── TemplateRequest.java │ │ ├── GitRequestRequest.java │ │ ├── CollectorRequest.java │ │ ├── AuthenticationRequest.java │ │ ├── PipelineSearchRequest.java │ │ ├── DataSyncResponse.java │ │ ├── RallyFeatureRequest.java │ │ ├── ServiceRequest.java │ │ ├── CreateTemplateRequest.java │ │ ├── LibraryPolicyRequest.java │ │ ├── PerformanceSearchRequest.java │ │ ├── InfraStructureRequest.java │ │ ├── BinaryArtifactSearchRequest.java │ │ └── CodeQualityRequest.java │ │ ├── util │ │ ├── TestResultConstants.java │ │ ├── URLConnectionFactory.java │ │ └── PaginationHeaderUtility.java │ │ ├── rest │ │ ├── InfraStructureController.java │ │ ├── UserInfoController.java │ │ ├── LogAnalysisController.java │ │ ├── ScoreController.java │ │ ├── PipelineController.java │ │ ├── EncryptionController.java │ │ ├── TeamInventoryController.java │ │ ├── MaturityModelController.java │ │ ├── CollectorItemController.java │ │ ├── LibraryPolicyController.java │ │ ├── PingController.java │ │ ├── ScoreCriteriaSettingsController.java │ │ └── ConfigurationController.java │ │ ├── editors │ │ ├── CaseInsensitiveBuildStatusEditor.java │ │ ├── CaseInsensitiveServiceStatusEditor.java │ │ ├── CaseInsensitiveCollectorTypeEditor.java │ │ ├── CaseInsensitiveTestSuiteTypeEditor.java │ │ ├── CaseInsensitiveCodeQualityTypeEditor.java │ │ └── CaseInsensitiveScoreValueTypeEditor.java │ │ ├── config │ │ ├── monitor │ │ │ └── ProxyAuthenticator.java │ │ └── LoggingConfig.java │ │ ├── mapper │ │ ├── CustomObjectMapper.java │ │ └── ObjectIdSerializer.java │ │ └── logging │ │ ├── DatabaseLoggingCondition.java │ │ └── KeyValueLoggingCondition.java ├── test │ ├── resources │ │ ├── com │ │ │ └── capitalone │ │ │ │ └── dashboard │ │ │ │ ├── rest │ │ │ │ ├── remotedb-empty.json │ │ │ │ ├── remotedb-repo.json │ │ │ │ ├── codequality.json │ │ │ │ └── remotedb-repo-build.json │ │ │ │ └── service │ │ │ │ ├── artifact1.json │ │ │ │ ├── rundeck_request.xml │ │ │ │ └── coll.json │ │ ├── configuration.json │ │ ├── test.properties │ │ ├── cloudinstance-history.json │ │ ├── dashboardRemoteRequests │ │ │ ├── Remote-Request-Base.json │ │ │ ├── Remote-Request-Base-Invalid-Users.json │ │ │ ├── Remote-Request-Create-Invalid-Valid-Users.json │ │ │ ├── 0-Remote-Update-All-Empty.json │ │ │ └── 0-Remote-Update-Repo.json │ │ ├── cloud-subnet-87654321.json │ │ ├── cloud-subnet-12345678.json │ │ ├── userInfo │ │ │ └── user.json │ │ ├── cloudinstance-9876543.json │ │ ├── GithubWebhook │ │ │ └── commit-node-1.json │ │ ├── cloudinstance-12345678.json │ │ └── test_cases.txt │ └── java │ │ └── com │ │ └── capitalone │ │ └── dashboard │ │ ├── util │ │ ├── WidgetOptionsBuilder.java │ │ └── PaginationHeaderUtilityTest.java │ │ ├── auth │ │ ├── ldap │ │ │ ├── LdapAuthenticationDetailsSourceTest.java │ │ │ └── LdapLoginRequestFilterTest.java │ │ ├── AuthenticationResultHandlerTest.java │ │ ├── AuthPropertiesTest.java │ │ ├── standard │ │ │ └── StandardAuthenticationProviderTest.java │ │ ├── apitoken │ │ │ └── ApiTokenAuthenticationProviderTest.java │ │ └── AuthenticationUtilTest.java │ │ ├── config │ │ ├── SpringDataTestConfig.java │ │ ├── monitor │ │ │ └── ProxyAuthenticatorTest.java │ │ └── ApiTestConfig.java │ │ ├── service │ │ ├── ApiTokenServiceTest.java │ │ └── AuthenticationServiceTest.java │ │ └── model │ │ └── MonitorServiceTest.java └── site │ ├── xdoc │ └── index.xml │ └── site.xml ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .whitesource ├── .gitignore ├── Dockerfile ├── config.env ├── Dockerfile.build └── .travis.yml /docker/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | @Hygieia/api -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | tabladrum 2 | satishc1 3 | rvema 4 | nireesht 5 | sbrenthughes 6 | -------------------------------------------------------------------------------- /src/devops/keys.gpg.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hygieia/api/HEAD/src/devops/keys.gpg.enc -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hygieia/api/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/version.properties: -------------------------------------------------------------------------------- 1 | version.number=@project.version@ 2 | application.name=hygieia-api-ace -------------------------------------------------------------------------------- /src/devops/deploy-snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp src/devops/.travis.settings.xml $HOME/.m2/settings.xml 4 | 5 | mvn deploy -q -------------------------------------------------------------------------------- /src/test/resources/com/capitalone/dashboard/rest/remotedb-empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaData": { 3 | "applicationName": "AppNm", 4 | "componentName": "BusComp" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/configuration.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "collectorName" : "testCollector", 3 | "info" : [ 4 | { 5 | "url" : "http://testurl.domain:9000", 6 | "password": "password" 7 | } 8 | ] 9 | }] -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/github/GitHubPayloadType.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.github; 2 | 3 | public enum GitHubPayloadType { 4 | Push, 5 | PullRequest, 6 | Issues, 7 | Unknown 8 | } 9 | 10 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar 3 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "scanSettings": { 3 | "baseBranches": [] 4 | }, 5 | "checkRunSettings": { 6 | "vulnerableCheckRunConclusionLevel": "failure", 7 | "displayMode": "diff" 8 | }, 9 | "issueSettings": { 10 | "minSeverityLevel": "LOW" 11 | } 12 | } -------------------------------------------------------------------------------- /src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | auth.secret=hygieiasecret 2 | 3 | auth.ldapServerUrl=ldap://company.com:389 4 | 5 | #if using standard ldap 6 | auth.ldapUserDnPattern= 7 | 8 | #if using ActiveDirectory 9 | auth.adDomain=company.com 10 | auth.adUrl=ldap://company.com:389 11 | auth.adRootDn=dc=your,dc=company,dc=com 12 | auth.expirationTime = 120000 -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/BusCompOwnerService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import org.springframework.security.core.Authentication; 4 | 5 | public interface BusCompOwnerService { 6 | 7 | void assignOwnerToDashboards(String firstName, String middleName, String lastName, Authentication authentication); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/MaturityModelService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.MaturityModel; 4 | 5 | import java.util.List; 6 | 7 | public interface MaturityModelService { 8 | 9 | MaturityModel getMaturityModel(String profile); 10 | List getProfiles(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/ApiTokenResponse.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | public class ApiTokenResponse { 4 | private String apiKey; 5 | 6 | public String getApiKey() { 7 | return apiKey; 8 | } 9 | 10 | public void setApiKey(String apiKey) { 11 | this.apiKey = apiKey; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/EncryptionService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | public interface EncryptionService { 4 | 5 | /** 6 | * Encrypts a string. 7 | * 8 | * @param message to encrypt 9 | * @return encrypted message 10 | */ 11 | String encrypt(String message); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.sso; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.security.core.Authentication; 6 | 7 | public interface SsoAuthenticationService { 8 | 9 | Authentication getAuthenticationFromHeaders(Map requestHeadersMap); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/webhook/github/GithubWebHookAuthService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.webhook.github; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import javax.servlet.http.HttpServletRequest; 5 | 6 | public interface GithubWebHookAuthService { 7 | Authentication getAuthentication(HttpServletRequest request); 8 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/TeamInventoryService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.TeamInventory; 5 | 6 | public interface TeamInventoryService { 7 | 8 | DataResponse getTeamData(String teamName, String teamId); 9 | } 10 | -------------------------------------------------------------------------------- /src/devops/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp src/devops/.travis.settings.xml $HOME/.m2/settings.xml 4 | 5 | openssl aes-256-cbc -K $encrypted_31f80473c41e_key -iv $encrypted_31f80473c41e_iv -in src/devops/keys.gpg.enc -out keys.gpg -d 6 | 7 | gpg --fast-import keys.gpg 8 | 9 | shred keys.gpg 10 | 11 | sed -i 's|-SNAPSHOT||g' pom.xml 12 | 13 | mvn deploy -q -P release 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/AuthenticationResponseService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth; 2 | 3 | import javax.servlet.http.HttpServletResponse; 4 | 5 | import org.springframework.security.core.Authentication; 6 | 7 | public interface AuthenticationResponseService { 8 | 9 | void handle(HttpServletResponse response, Authentication authentication); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac artifacts 2 | .DS_Store 3 | 4 | # Eclipse artifacts 5 | .project 6 | .settings 7 | .classpath 8 | 9 | # Logs 10 | logs 11 | log 12 | *.log 13 | 14 | # Runtime data 15 | pids 16 | *.pid 17 | *.seed 18 | *.iml 19 | /target 20 | /.idea 21 | 22 | # Distributable artifacts 23 | target 24 | 25 | # Specific project files 26 | jir-client.properties 27 | /bin/ 28 | application.properties 29 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/CollectorItemService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | 5 | public interface CollectorItemService { 6 | /** 7 | * Removing CollectorItems that are not connected 8 | * to a Dashboard 9 | * */ 10 | ResponseEntity cleanup(String collectorType, String collectorName); 11 | } 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre 2 | 3 | VOLUME ["/hygieia/logs"] 4 | 5 | RUN mkdir /hygieia/config 6 | 7 | EXPOSE 8080 8 | 9 | ENV PROP_FILE /hygieia/config/application.properties 10 | 11 | WORKDIR /hygieia 12 | 13 | COPY target/*.jar /hygieia/ 14 | COPY docker/properties-builder.sh /hygieia/ 15 | 16 | CMD ./properties-builder.sh &&\ 17 | java -Djava.security.egd=file:/dev/./urandom -jar *.jar --spring.config.location=$PROP_FILE -------------------------------------------------------------------------------- /config.env: -------------------------------------------------------------------------------- 1 | #Use following argument to update your DB information outside your docker host 2 | SPRING_DATA_MONGODB_DATABASE= 3 | SPRING_DATA_MONGODB_HOST= 4 | SPRING_DATA_MONGODB_PORT= 5 | SPRING_DATA_MONGODB_PASSWORD= 6 | SPRING_DATA_MONGODB_USERNAME= 7 | #See https://hygieia.github.io/Hygieia/setup.html#encryption-for-private-repos 8 | KEY=<> 9 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/EncryptionRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | public class EncryptionRequest extends BaseRequest { 6 | @NotNull 7 | private String message; 8 | 9 | public String getMessage() { 10 | return message; 11 | } 12 | 13 | public void setMessage(String message) { 14 | this.message = message; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/FeatureFlagService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.FeatureFlag; 4 | import org.bson.types.ObjectId; 5 | 6 | import java.util.List; 7 | 8 | public interface FeatureFlagService { 9 | String createOrUpdateFlags(String json) ; 10 | List getFeatureFlags(); 11 | void deleteFlags(ObjectId id); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/maven-pr-checks.yml: -------------------------------------------------------------------------------- 1 | name: Java Compile and Test 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v1 13 | - name: Set up JDK 11 14 | uses: actions/setup-java@v1 15 | with: 16 | java-version: 11 17 | - name: Build with Maven 18 | run: mvn test --file pom.xml 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/LogAnalysisService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.LogAnalysis; 5 | import com.capitalone.dashboard.request.LogAnalysisSearchRequest; 6 | 7 | public interface LogAnalysisService { 8 | 9 | DataResponse> search(LogAnalysisSearchRequest value); 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/datasync/DataSyncService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.datasync; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.request.DataSyncRequest; 5 | import com.capitalone.dashboard.request.DataSyncResponse; 6 | 7 | public interface DataSyncService { 8 | 9 | DataSyncResponse refresh(DataSyncRequest request) throws HygieiaException; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/FeatureFlagRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | public class FeatureFlagRequest extends BaseRequest { 6 | 7 | @NotNull 8 | private String json; 9 | 10 | public String getJson() { 11 | return json; 12 | } 13 | 14 | public void setJson(String json) { 15 | this.json = json; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/cloudinstance-history.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountNumber" : "123456789", 3 | "time" : 1462505132647, 4 | "total" : 295, 5 | "nonTagged" : 94, 6 | "stopped" : 12, 7 | "expiredImage" : 0, 8 | "estimatedCharge" : 0.0, 9 | "cpu" : 4.437895866636435, 10 | "diskRead" : 3241.162485875707, 11 | "diskWrite" : 9565.250562273119, 12 | "networkIn" : 2396777.2433030307, 13 | "networkOut" : 2319656.765502381, 14 | "currency" : "USD" 15 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/ConfigurationService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.capitalone.dashboard.model.Configuration; 8 | 9 | @Service 10 | public interface ConfigurationService { 11 | List insertConfigurationData(List config); 12 | 13 | List getConfigurationData(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/InfraStructureService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.InfrastructureScan; 5 | import com.capitalone.dashboard.request.InfraStructureRequest; 6 | 7 | public interface InfraStructureService { 8 | DataResponse> getInfraScanForWidget(InfraStructureRequest request); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/exceptions/DeleteLastAdminException.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.exceptions; 2 | 3 | public class DeleteLastAdminException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = -4670507474875127809L; 6 | private static final String MESSAGE = "There must always be at least one admin"; 7 | 8 | public DeleteLastAdminException() { 9 | super(MESSAGE); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/AutoDiscoveryService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.AutoDiscovery; 5 | import com.capitalone.dashboard.model.AutoDiscoveryRemoteRequest; 6 | 7 | public interface AutoDiscoveryService { 8 | public AutoDiscovery save(AutoDiscoveryRemoteRequest request) throws HygieiaException; 9 | } 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/CloudRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import org.bson.types.ObjectId; 4 | 5 | import javax.validation.constraints.NotNull; 6 | 7 | public class CloudRequest extends BaseRequest { 8 | @NotNull 9 | private ObjectId id; 10 | 11 | public ObjectId getId() { 12 | return id; 13 | } 14 | 15 | public void setId(ObjectId id) { 16 | this.id = id; 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/DashboardRemoteService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.Dashboard; 5 | import com.capitalone.dashboard.request.DashboardRemoteRequest; 6 | 7 | public interface DashboardRemoteService { 8 | Dashboard remoteCreate(DashboardRemoteRequest request, boolean isUpdate) throws HygieiaException; 9 | } 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/github/GitHubHookService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.github; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import org.json.simple.JSONObject; 5 | import org.json.simple.parser.ParseException; 6 | 7 | import java.net.MalformedURLException; 8 | 9 | public interface GitHubHookService { 10 | String createFromGitHubv3(JSONObject request) throws ParseException, HygieiaException, MalformedURLException; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/DataSyncRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | public class DataSyncRequest extends BaseRequest { 6 | @NotNull 7 | private String collectorName; 8 | 9 | public String getCollectorName() { 10 | return collectorName; 11 | } 12 | 13 | public void setCollectorName(String collectorName) { 14 | this.collectorName = collectorName; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/dashboardRemoteRequests/Remote-Request-Base.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaData": 3 | { 4 | "applicationName":"test1", 5 | "componentName":"test1", 6 | "owner": 7 | { 8 | "authType":"STANDARD", 9 | "username":"topopal" 10 | }, 11 | "owners": 12 | [ 13 | { 14 | "authType":"STANDARD", 15 | "username":"testuser1" 16 | } 17 | ], 18 | "template":"CapOne", 19 | "title":"testTitle", 20 | "type":"Team" 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/deploy/Server.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model.deploy; 2 | 3 | public class Server { 4 | private final String name; 5 | private final boolean online; 6 | 7 | public Server(String name, boolean online) { 8 | this.name = name; 9 | this.online = online; 10 | } 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public boolean isOnline() { 17 | return online; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/util/TestResultConstants.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.util; 2 | 3 | public class TestResultConstants { 4 | 5 | public static final String PERFORMANCE = "performance" ; 6 | 7 | public static final String FUNCTIONAL = "functional"; 8 | 9 | public static final String UNIT = "unit"; 10 | 11 | public static final String JENKINSCUCUMBERTEST ="JenkinsCucumberTest"; 12 | 13 | public static final String JUNITTEST = "JunitTest"; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/rest/InfraStructureController.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.rest; 2 | 3 | import com.capitalone.dashboard.service.InfraStructureService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class InfraStructureController { 9 | 10 | @Autowired 11 | public InfraStructureController(InfraStructureService infraStructureService) { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/github/GitHubSyncService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.github; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.request.GitSyncRequest; 5 | import org.json.simple.parser.ParseException; 6 | 7 | import java.net.MalformedURLException; 8 | 9 | public interface GitHubSyncService { 10 | String syncGithubRepo(GitSyncRequest request) throws ParseException, HygieiaException, MalformedURLException; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/openid/OpenIdAuthenticationService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.openid; 2 | 3 | import org.springframework.security.core.Authentication; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | public interface OpenIdAuthenticationService { 9 | void addAuthentication(HttpServletResponse response, Authentication authentication); 10 | Authentication getAuthentication(HttpServletRequest request); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/token/TokenAuthenticationService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.token; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.security.core.Authentication; 7 | 8 | public interface TokenAuthenticationService { 9 | 10 | void addAuthentication(HttpServletResponse response, Authentication authentication); 11 | Authentication getAuthentication(HttpServletRequest request); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/GenericCollectorItemService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.request.GenericCollectorItemCreateRequest; 5 | 6 | public interface GenericCollectorItemService { 7 | String create(GenericCollectorItemCreateRequest request) throws HygieiaException; 8 | String createGenericBinaryArtifactData(GenericCollectorItemCreateRequest request) throws HygieiaException; 9 | } 10 | -------------------------------------------------------------------------------- /src/test/java/com/capitalone/dashboard/util/WidgetOptionsBuilder.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class WidgetOptionsBuilder { 7 | private Map options = new HashMap(); 8 | 9 | public Map get() { 10 | return options; 11 | } 12 | 13 | public WidgetOptionsBuilder put(String key, Object value) { 14 | options.put(key, value); 15 | return this; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/LoginCredentials.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | public class LoginCredentials { 4 | 5 | private String username; 6 | private String password; 7 | 8 | public String getUsername() { 9 | return username; 10 | } 11 | 12 | public void setUsername(String username) { 13 | this.username = username; 14 | } 15 | 16 | public String getPassword() { 17 | return password; 18 | } 19 | 20 | public void setPassword(String password) { 21 | this.password = password; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/WidgetResponse.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | public class WidgetResponse { 4 | private final Component component; 5 | private final Widget widget; 6 | 7 | public WidgetResponse(Component component, Widget widget) { 8 | this.component = component; 9 | this.widget = widget; 10 | } 11 | 12 | public Component getComponent() { 13 | return component; 14 | } 15 | 16 | public Widget getWidget() { 17 | return widget; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/ScoreService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.score.ScoreMetric; 5 | import org.bson.types.ObjectId; 6 | 7 | public interface ScoreService { 8 | 9 | /** 10 | * Score Metrics by dashboard id 11 | * 12 | * @param dashboardId id of dashboard 13 | * @return DataResponse of type Scores 14 | */ 15 | DataResponse getScoreMetric(ObjectId dashboardId); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/TemplateResponse.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | public class TemplateResponse { 4 | private final Component component; 5 | private final Widget widget; 6 | 7 | public TemplateResponse(Component component, Widget widget) { 8 | this.component = component; 9 | this.widget = widget; 10 | } 11 | 12 | public Component getComponent() { 13 | return component; 14 | } 15 | 16 | public Widget getWidget() { 17 | return widget; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/capitalone/dashboard/auth/ldap/LdapAuthenticationDetailsSourceTest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.ldap; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import com.capitalone.dashboard.model.AuthType; 8 | 9 | public class LdapAuthenticationDetailsSourceTest { 10 | 11 | @Test 12 | public void test() { 13 | LdapAuthenticationDetailsSource detailsSource = new LdapAuthenticationDetailsSource(); 14 | assertEquals(AuthType.LDAP, detailsSource.buildDetails(null)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/capitalone/dashboard/config/SpringDataTestConfig.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.web.config.EnableSpringDataWebSupport; 5 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; 7 | 8 | @Configuration 9 | @EnableWebMvc 10 | @EnableSpringDataWebSupport 11 | public class SpringDataTestConfig extends WebMvcConfigurationSupport {} 12 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/ServiceAccountService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.ServiceAccount; 4 | import org.bson.types.ObjectId; 5 | 6 | import java.util.Collection; 7 | 8 | public interface ServiceAccountService { 9 | String createAccount(String serviceAccount, String fileNames) ; 10 | String updateAccount(String serviceAccount, String fileNames, ObjectId id); 11 | Collection getAllServiceAccounts(); 12 | void deleteAccount(ObjectId id); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/ldap/LdapAuthenticationDetailsSource.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.ldap; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.security.authentication.AuthenticationDetailsSource; 6 | 7 | import com.capitalone.dashboard.model.AuthType; 8 | 9 | public class LdapAuthenticationDetailsSource implements AuthenticationDetailsSource { 10 | 11 | @Override 12 | public AuthType buildDetails(HttpServletRequest context) { 13 | return AuthType.LDAP; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/InsertStatus.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | public enum InsertStatus { 4 | Created, 5 | Updated, 6 | Duplicate, 7 | Failed, 8 | Unknown; 9 | 10 | public static InsertStatus fromString(String value) { 11 | for (InsertStatus status : values()) { 12 | if (status.toString().equalsIgnoreCase(value)) { 13 | return status; 14 | } 15 | } 16 | throw new IllegalArgumentException(value + " is not a valid InsertStatus."); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/ScoreCriteriaSettingsService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.score.ScoreValueType; 4 | import com.capitalone.dashboard.model.score.settings.ScoreCriteriaSettings; 5 | 6 | public interface ScoreCriteriaSettingsService { 7 | 8 | /** 9 | * Fetch ScoreCriteriaSettings by ScoreValueType 10 | * 11 | * @param type ScoreValueType 12 | * @return ScoreCriteriaSettings 13 | */ 14 | ScoreCriteriaSettings getScoreCriteriaSettingsByType(ScoreValueType type); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/CmdbRemoteService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.Cmdb; 5 | import com.capitalone.dashboard.request.CmdbRequest; 6 | 7 | public interface CmdbRemoteService { 8 | /** 9 | * Creates new Cmdb Item 10 | * @param request 11 | * @return newly created Cmdb Item 12 | * @throws HygieiaException 13 | */ 14 | Cmdb remoteCreate(CmdbRequest request ) throws HygieiaException; 15 | } 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test/resources/com/capitalone/dashboard/service/artifact1.json: -------------------------------------------------------------------------------- 1 | { 2 | "artifactName": "Helloworld", 3 | "canonicalName": "Helloworld", 4 | "artifactGroup": "com.capitalone.helloworld", 5 | "artifactVersion": "1.0.0", 6 | "timestamp": 1473776278638, 7 | "metadata" : { 8 | "jobName" : "job_helloworld", 9 | "buildUrl" : "http://myjenkins:8080/job/job_helloworld/1/", 10 | "jobUrl" : "http://myjenkins:8080/job/job_helloworld/", 11 | "buildNumber" : 1, 12 | "instanceUrl" : "http://myjenkins:8080/", 13 | "foo": "bar" 14 | } 15 | } -------------------------------------------------------------------------------- /.github/workflows/maven-snapshot-release.yml: -------------------------------------------------------------------------------- 1 | name: Release Snapshot 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-18.04 11 | 12 | steps: 13 | - uses: actions/checkout@v1 14 | - name: Set up JDK 1.8 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: 1.8 18 | - name: Release to snapshots repository 19 | run: mvn deploy -q --file pom.xml --settings src/devops/.travis.settings.xml -Denv.OSSRH_USERNAME=${{ secrets.OSSRH_USERNAME }} -Denv.OSSRH_PASSWORD=${{ secrets.OSSRH_PASSWORD }} 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/editors/CaseInsensitiveBuildStatusEditor.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.editors; 2 | 3 | import com.capitalone.dashboard.model.BuildStatus; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | /** 8 | * Property editor that translates text into a BuildStatus in a case insensitive manner. 9 | */ 10 | public class CaseInsensitiveBuildStatusEditor extends PropertyEditorSupport { 11 | 12 | @Override 13 | public void setAsText(String text) throws IllegalArgumentException { 14 | setValue(BuildStatus.fromString(text)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/editors/CaseInsensitiveServiceStatusEditor.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.editors; 2 | 3 | import com.capitalone.dashboard.model.ServiceStatus; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | /** 8 | * Property editor that translates text into a BuildStatus in a case insensitive manner. 9 | */ 10 | public class CaseInsensitiveServiceStatusEditor extends PropertyEditorSupport { 11 | @Override 12 | public void setAsText(String text) throws IllegalArgumentException { 13 | setValue(ServiceStatus.fromString(text)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/editors/CaseInsensitiveCollectorTypeEditor.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.editors; 2 | 3 | import com.capitalone.dashboard.model.CollectorType; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | /** 8 | * Property editor that translates text into a CollectorType in a case insensitive manner. 9 | */ 10 | public class CaseInsensitiveCollectorTypeEditor extends PropertyEditorSupport { 11 | @Override 12 | public void setAsText(String text) throws IllegalArgumentException { 13 | setValue(CollectorType.fromString(text)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/editors/CaseInsensitiveTestSuiteTypeEditor.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.editors; 2 | 3 | import com.capitalone.dashboard.model.TestSuiteType; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | /** 8 | * Property editor that translates text into a TestSuiteType in a case insensitive manner. 9 | */ 10 | public class CaseInsensitiveTestSuiteTypeEditor extends PropertyEditorSupport { 11 | @Override 12 | public void setAsText(String text) throws IllegalArgumentException { 13 | setValue(TestSuiteType.fromString(text)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/editors/CaseInsensitiveCodeQualityTypeEditor.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.editors; 2 | 3 | import com.capitalone.dashboard.model.CodeQualityType; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | /** 8 | * Property editor that translates text into a CodeQualityType in a case insensitive manner. 9 | */ 10 | public class CaseInsensitiveCodeQualityTypeEditor extends PropertyEditorSupport { 11 | @Override 12 | public void setAsText(String text) throws IllegalArgumentException { 13 | setValue(CodeQualityType.fromString(text)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/editors/CaseInsensitiveScoreValueTypeEditor.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.editors; 2 | 3 | import com.capitalone.dashboard.model.score.ScoreValueType; 4 | 5 | import java.beans.PropertyEditorSupport; 6 | 7 | /** 8 | * Property editor that translates text into a ScoreValueType in a case insensitive manner. 9 | */ 10 | public class CaseInsensitiveScoreValueTypeEditor extends PropertyEditorSupport { 11 | @Override 12 | public void setAsText(String text) throws IllegalArgumentException { 13 | setValue(ScoreValueType.fromString(text)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/exceptions/UserNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.exceptions; 2 | 3 | import com.capitalone.dashboard.model.AuthType; 4 | 5 | public class UserNotFoundException extends RuntimeException { 6 | 7 | private static final long serialVersionUID = -8596676033217258687L; 8 | 9 | private static final String MESSAGE = "No user found with name: %1$2s, and authorization type %2$2s."; 10 | 11 | public UserNotFoundException(String username, AuthType authType) { 12 | super(String.format(MESSAGE, username, authType.name())); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/config/monitor/ProxyAuthenticator.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.config.monitor; 2 | 3 | import java.net.Authenticator; 4 | import java.net.PasswordAuthentication; 5 | 6 | public class ProxyAuthenticator extends Authenticator { 7 | 8 | private PasswordAuthentication passwordAuthentication; 9 | 10 | public ProxyAuthenticator(PasswordAuthentication passwordAuthentication) { 11 | this.passwordAuthentication = passwordAuthentication; 12 | } 13 | 14 | @Override 15 | protected PasswordAuthentication getPasswordAuthentication() { 16 | return passwordAuthentication; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/DashboardRequestTitle.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | import javax.validation.constraints.Pattern; 5 | import javax.validation.constraints.Size; 6 | 7 | public class DashboardRequestTitle extends BaseRequest { 8 | 9 | @NotNull 10 | @Size(min = 6, max = 50) 11 | @Pattern(message = "Special character(s) found", regexp = "^[a-zA-Z0-9 ]*$") 12 | private String title; 13 | 14 | public String getTitle() { 15 | return title; 16 | } 17 | 18 | public void setTitle(String title) { 19 | this.title = title; 20 | } 21 | } -------------------------------------------------------------------------------- /src/test/resources/com/capitalone/dashboard/rest/remotedb-repo.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaData": { 3 | "applicationName": "AppNm", 4 | "businessApplication": "BusApp", 5 | "businessService": "BusSvc", 6 | "componentName": "BusComp", 7 | "owner": { 8 | "authType": "STANDARD", 9 | "username": "topopal" 10 | }, 11 | "template": "CapOne", 12 | "title": "AutoDashTitle", 13 | "type": "Team" 14 | }, 15 | "codeRepoEntries": [ 16 | { 17 | "toolName": "GitHub", 18 | "options": { 19 | "branch": "master", 20 | "url": "http://test.git.com" 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/PipelineService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.PipelineResponse; 5 | import com.capitalone.dashboard.request.PipelineSearchRequest; 6 | 7 | public interface PipelineService { 8 | 9 | /** 10 | * Retrieves all pipeline objects based on the provided search criteria. 11 | * 12 | * @param searchRequest search request 13 | * @return all pipelines for team dashboards 14 | */ 15 | Iterable search(PipelineSearchRequest searchRequest) throws HygieiaException; 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/dashboardRemoteRequests/Remote-Request-Base-Invalid-Users.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaData": 3 | { 4 | "applicationName":"test1", 5 | "componentName":"test1", 6 | "owner": 7 | { 8 | "authType":"STANDARD", 9 | "username":"test123" 10 | }, 11 | "owners": [ 12 | { 13 | "authType":"STANDARD", 14 | "username":"doesnotexist123" 15 | }, 16 | { 17 | "authType":"STANDARD", 18 | "username":"doesnotexist" 19 | } 20 | ], 21 | "template":"CapOne", 22 | "title":"testTitle", 23 | "type":"Team" 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/MetadataService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.Dashboard; 5 | import com.capitalone.dashboard.model.DataResponse; 6 | import com.capitalone.dashboard.model.Metadata; 7 | import com.capitalone.dashboard.request.MetadataCreateRequest; 8 | import org.json.simple.JSONObject; 9 | 10 | public interface MetadataService { 11 | 12 | String create(MetadataCreateRequest request) throws HygieiaException; 13 | 14 | 15 | DataResponse> search(String searchKey, String value) throws HygieiaException; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/capitalone/dashboard/config/monitor/ProxyAuthenticatorTest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.config.monitor; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.net.PasswordAuthentication; 6 | 7 | import org.junit.Test; 8 | 9 | public class ProxyAuthenticatorTest { 10 | 11 | private ProxyAuthenticator proxyAuthenticator; 12 | 13 | @Test 14 | public void testGetPasswordAuthentication() { 15 | PasswordAuthentication expected = new PasswordAuthentication("username", "password".toCharArray()); 16 | proxyAuthenticator = new ProxyAuthenticator(expected); 17 | 18 | assertEquals(expected, proxyAuthenticator.getPasswordAuthentication()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/sonarqube/SonarQubeHookService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.sonarqube; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.request.SonarDataSyncRequest; 5 | import org.json.simple.JSONObject; 6 | import org.json.simple.parser.ParseException; 7 | import org.springframework.http.ResponseEntity; 8 | 9 | import java.net.MalformedURLException; 10 | 11 | public interface SonarQubeHookService { 12 | String createFromSonarQubeV1(JSONObject request) throws ParseException, HygieiaException, MalformedURLException; 13 | ResponseEntity syncData(SonarDataSyncRequest request) throws HygieiaException; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/mapper/CustomObjectMapper.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.mapper; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.databind.module.SimpleModule; 5 | import org.bson.types.ObjectId; 6 | 7 | /** 8 | * Custom object mapper that knows how to serialize Mongo ObjectIds. 9 | */ 10 | public class CustomObjectMapper extends ObjectMapper { 11 | private static final long serialVersionUID = 2035695746790240402L; 12 | 13 | public CustomObjectMapper() { 14 | SimpleModule module = new SimpleModule("ObjectIdModule"); 15 | module.addSerializer(ObjectId.class, new ObjectIdSerializer()); 16 | this.registerModule(module); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/access/Admin.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.access; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | import org.springframework.security.access.prepost.PreAuthorize; 11 | 12 | @Target({ElementType.METHOD, ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Inherited 15 | @Documented 16 | @PreAuthorize(Admin.HAS_ROLE_ROLE_ADMIN) 17 | public @interface Admin { 18 | 19 | static final String HAS_ROLE_ROLE_ADMIN = "hasRole('ROLE_ADMIN')"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/logging/DatabaseLoggingCondition.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.logging; 2 | 3 | import org.springframework.context.annotation.Condition; 4 | import org.springframework.context.annotation.ConditionContext; 5 | import org.springframework.core.type.AnnotatedTypeMetadata; 6 | 7 | public class DatabaseLoggingCondition implements Condition { 8 | 9 | protected static final String LOG_REQUEST = "logRequest"; 10 | 11 | @Override 12 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 13 | String logRequest = context.getEnvironment().getProperty(LOG_REQUEST); 14 | return logRequest != null && Boolean.parseBoolean(logRequest); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/RallyFeatureService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import java.util.List; 4 | 5 | import com.capitalone.dashboard.model.CollectorItem; 6 | import com.capitalone.dashboard.model.RallyFeature; 7 | import com.capitalone.dashboard.request.RallyFeatureRequest; 8 | import com.capitalone.dashboard.response.RallyBurnDownResponse; 9 | public interface RallyFeatureService { 10 | 11 | CollectorItem getCollectorItem(RallyFeatureRequest request); 12 | List rallyProjectIterationType(String projectId); 13 | 14 | 15 | List rallyWidgetDataDetails(CollectorItem item); 16 | 17 | RallyBurnDownResponse rallyBurnDownData(RallyFeature request); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/LogAnalysisSearchRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import org.bson.types.ObjectId; 4 | 5 | import javax.validation.constraints.NotNull; 6 | 7 | public class LogAnalysisSearchRequest extends BaseRequest { 8 | 9 | @NotNull 10 | private ObjectId componentId; 11 | 12 | private Integer max; 13 | 14 | public ObjectId getComponentId() { 15 | return componentId; 16 | } 17 | 18 | public void setComponentId(ObjectId componentId) { 19 | this.componentId = componentId; 20 | } 21 | 22 | public Integer getMax() { 23 | return max; 24 | } 25 | 26 | public void setMax(Integer max) { 27 | this.max = max; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Dockerfile.build: -------------------------------------------------------------------------------- 1 | # our base build image 2 | FROM maven:3.6-jdk-8 as build 3 | 4 | # copy the project files 5 | COPY ./pom.xml ./pom.xml 6 | 7 | # build all dependencies 8 | # RUN mvn dependency:go-offline -B 9 | 10 | # copy your other files 11 | COPY ./src ./src 12 | 13 | # build for release 14 | RUN mvn package 15 | 16 | 17 | FROM openjdk:8-jre 18 | 19 | VOLUME ["/hygieia/logs"] 20 | 21 | RUN mkdir /hygieia/config 22 | 23 | EXPOSE 8080 24 | 25 | ENV PROP_FILE /hygieia/config/application.properties 26 | 27 | WORKDIR /hygieia 28 | 29 | COPY --from=build target/*.jar /hygieia/ 30 | COPY docker/properties-builder.sh /hygieia/ 31 | 32 | CMD ./properties-builder.sh &&\ 33 | java -Djava.security.egd=file:/dev/./urandom -jar *.jar --spring.config.location=$PROP_FILE -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/ApiTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | public class ApiTokenRequest extends BaseRequest{ 6 | 7 | @NotNull 8 | private String apiUser; 9 | 10 | @NotNull 11 | private Long expirationDt; 12 | 13 | public ApiTokenRequest() { 14 | 15 | } 16 | 17 | public String getApiUser() { 18 | return apiUser; 19 | } 20 | 21 | public void setApiUser(String apiUser) { 22 | this.apiUser = apiUser; 23 | } 24 | 25 | public Long getExpirationDt() { 26 | return expirationDt; 27 | } 28 | 29 | public void setExpirationDt(Long expirationDt) { 30 | this.expirationDt = expirationDt; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/logging/KeyValueLoggingCondition.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.logging; 2 | 3 | import org.springframework.context.annotation.Condition; 4 | import org.springframework.context.annotation.ConditionContext; 5 | import org.springframework.core.type.AnnotatedTypeMetadata; 6 | 7 | public class KeyValueLoggingCondition implements Condition { 8 | 9 | protected static final String LOG_REQUEST_KEY_VALUE = "logRequestKeyValue"; 10 | 11 | @Override 12 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 13 | String logRequestKeyValue = context.getEnvironment().getProperty(LOG_REQUEST_KEY_VALUE); 14 | return logRequestKeyValue != null && Boolean.parseBoolean(logRequestKeyValue); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/mapper/ObjectIdSerializer.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.mapper; 2 | 3 | 4 | import com.fasterxml.jackson.core.JsonGenerator; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.JsonSerializer; 7 | import com.fasterxml.jackson.databind.SerializerProvider; 8 | import org.bson.types.ObjectId; 9 | 10 | import java.io.IOException; 11 | 12 | 13 | /** 14 | * Serialize Mongo ObjectId's as Strings. 15 | */ 16 | public class ObjectIdSerializer extends JsonSerializer { 17 | 18 | @Override 19 | public void serialize(ObjectId value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException { 20 | gen.writeString(value.toString()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/cloud-subnet-87654321.json: -------------------------------------------------------------------------------- 1 | { 2 | "subnetId" : "subnet-87654321", 3 | "accountNumber" : "123456789", 4 | "virtualNetworkId" : "vpc-87654321", 5 | "cidrBlock" : "10.111.22.0/25", 6 | "cidrCount" : 25, 7 | "zone" : "us-east-1a", 8 | "availableIPCount" : 73, 9 | "subscribedIPCount": 15, 10 | "usedIPCount" : 50, 11 | "defaultForZone" : false, 12 | "state" : "available", 13 | "creationDate" : 1463072005914, 14 | "lastUpdateDate" : 1463072005914, 15 | "tags" : [ 16 | { 17 | "name" : "aws:cloudformation:stack-id", 18 | "value" : "arn:aws:cloudformation:us-east-1:123456789:stack/MY-VPC/ed123456-7890-1111-ab12-123456789" 19 | } 20 | ], 21 | "ipUsage" : { 22 | "MYTAG" : 1 23 | }, 24 | "subscribedIPUsage": { 25 | "MYTAG": 1 26 | } 27 | } -------------------------------------------------------------------------------- /src/test/resources/dashboardRemoteRequests/Remote-Request-Create-Invalid-Valid-Users.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaData": 3 | { 4 | "applicationName":"test1", 5 | "componentName":"test1", 6 | "owner": 7 | { 8 | "authType":"STANDARD", 9 | "username":"topopal" 10 | }, 11 | "owners": [ 12 | { 13 | "authType":"STANDARD", 14 | "username":"doesnotexist123" 15 | }, 16 | { 17 | "authType":"STANDARD", 18 | "username":"doesnotexist" 19 | }, 20 | { 21 | "authType":"STANDARD", 22 | "username":"testuser1" 23 | } 24 | ], 25 | "template":"CapOne", 26 | "title":"testTitleInvalidValid", 27 | "type":"Team" 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/SonarDataSyncRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | public class SonarDataSyncRequest extends BaseRequest { 4 | 5 | private String syncFrom; 6 | private String syncTo; 7 | private boolean isSync; 8 | 9 | public String getSyncFrom() { 10 | return syncFrom; 11 | } 12 | 13 | public void setSyncFrom(String syncFrom) { 14 | this.syncFrom = syncFrom; 15 | } 16 | 17 | public String getSyncTo() { 18 | return syncTo; 19 | } 20 | 21 | public void setSyncTo(String syncTo) { 22 | this.syncTo = syncTo; 23 | } 24 | 25 | public boolean getIsSync() { 26 | return isSync; 27 | } 28 | 29 | public void setIsSync(boolean isSync) { 30 | this.isSync = isSync; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/util/URLConnectionFactory.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.util; 2 | 3 | import java.io.IOException; 4 | import java.net.HttpURLConnection; 5 | import java.net.Proxy; 6 | import java.net.URL; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class URLConnectionFactory { 13 | 14 | private Proxy proxy; 15 | 16 | @Autowired 17 | public URLConnectionFactory(Proxy proxy) { 18 | this.proxy = proxy; 19 | } 20 | 21 | public HttpURLConnection get(URL url) throws IOException { 22 | HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy); 23 | connection.setRequestMethod("GET"); 24 | connection.setConnectTimeout(5000); 25 | return connection; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/settings/WebHookSettings.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.settings; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationPropertiesBinding 8 | public class WebHookSettings { 9 | GitHubWebHookSettings gitHub; 10 | 11 | JenkinsBuildWebHookSettings jenkinsBuild; 12 | 13 | public GitHubWebHookSettings getGitHub() { return gitHub; } 14 | 15 | public void setGitHub(GitHubWebHookSettings gitHub) { this.gitHub = gitHub; } 16 | 17 | public JenkinsBuildWebHookSettings getJenkinsBuild() { return jenkinsBuild; } 18 | 19 | public void setJenkinsBuild(JenkinsBuildWebHookSettings jenkinsBuild) { this.jenkinsBuild = jenkinsBuild; } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/cloud-subnet-12345678.json: -------------------------------------------------------------------------------- 1 | { 2 | "subnetId" : "subnet-12345678", 3 | "accountNumber" : "123456789", 4 | "virtualNetworkId" : "vpc-12345678", 5 | "cidrBlock" : "10.111.22.0/25", 6 | "cidrCount" : 25, 7 | "zone" : "us-east-1a", 8 | "availableIPCount" : 73, 9 | "subscribedIPCount": 15, 10 | "usedIPCount" : 50, 11 | "subscribedIPCount": 190, 12 | "defaultForZone" : false, 13 | "state" : "available", 14 | "creationDate" : 1463072005914, 15 | "lastUpdateDate" : 1463072005914, 16 | "tags" : [ 17 | { 18 | "name" : "aws:cloudformation:stack-id", 19 | "value" : "arn:aws:cloudformation:us-east-1:123456789:stack/MY-VPC/ed123456-7890-1111-ab12-123456789" 20 | } 21 | ], 22 | "ipUsage" : { 23 | "MYTAG" : 1 24 | }, 25 | "subscribedIPUsage": { 26 | "MYTAG": 1 27 | } 28 | } -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - bug 8 | - enhancement 9 | - discussion 10 | # Label to use when marking an issue as stale 11 | staleLabel: wontfix 12 | # Comment to post when marking an issue as stale. Set to `false` to disable 13 | markComment: > 14 | This issue has been automatically marked as stale because it has not had 15 | recent activity. It will be closed if no further activity occurs. Thank you 16 | for your contributions. 17 | # Comment to post when closing a stale issue. Set to `false` to disable 18 | closeComment: false 19 | # Limit to only `issues` or `pulls` 20 | only: issues 21 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/ServiceAccountRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | public class ServiceAccountRequest extends BaseRequest { 6 | 7 | @NotNull 8 | private String serviceAccount; 9 | 10 | @NotNull 11 | private String fileNames; 12 | 13 | public ServiceAccountRequest() { 14 | 15 | } 16 | 17 | public String getServiceAccount() { 18 | return serviceAccount; 19 | } 20 | 21 | public void setServiceAccount(String serviceAccount) { 22 | this.serviceAccount = serviceAccount; 23 | } 24 | 25 | public String getFileNames() { 26 | return fileNames; 27 | } 28 | 29 | public void setFileNames(String fileNames) { 30 | this.fileNames = fileNames; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/TeamInventoryRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import org.bson.types.ObjectId; 4 | 5 | public class TeamInventoryRequest extends BaseRequest { 6 | 7 | private ObjectId componentId; 8 | private String teamId; 9 | private String teamName; 10 | 11 | 12 | public ObjectId getComponentId() { 13 | return componentId; 14 | } 15 | 16 | public void setComponentId(ObjectId componentId) { 17 | this.componentId = componentId; 18 | } 19 | 20 | public String getTeamId() { 21 | return teamId; 22 | } 23 | 24 | public void setTeamId(String teamId) { 25 | this.teamId = teamId; 26 | } 27 | 28 | public String getTeamName() { 29 | return teamName; 30 | } 31 | 32 | public void setTeamName(String teamName) { 33 | this.teamName = teamName; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/access/DashboardOwnerOrAdmin.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.access; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | import org.springframework.security.access.prepost.PreAuthorize; 11 | 12 | @Target({ElementType.METHOD, ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Inherited 15 | @Documented 16 | @PreAuthorize(DashboardOwnerOrAdmin.IS_DASHBOARD_OWNER_OR_ADMIN) 17 | public @interface DashboardOwnerOrAdmin { 18 | 19 | static final String IS_DASHBOARD_OWNER_OR_ADMIN = "@methodLevelSecurityHandler.isOwnerOfDashboard(#id) or hasRole('ROLE_ADMIN')"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/PerformanceService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.DataResponse; 5 | import com.capitalone.dashboard.model.Performance; 6 | import com.capitalone.dashboard.request.PerformanceCreateRequest; 7 | import com.capitalone.dashboard.request.PerformanceSearchRequest; 8 | 9 | public interface PerformanceService { 10 | 11 | /** 12 | * Finds all of the CodeQuality data matching the specified request criteria. 13 | * 14 | * @param request search criteria 15 | * @return quality data matching criteria 16 | */ 17 | DataResponse> search(PerformanceSearchRequest request); 18 | String create(PerformanceCreateRequest request) throws HygieiaException; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/DataResponse.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | public class DataResponse { 4 | private final T result; 5 | private final long lastUpdated; 6 | private String reportUrl; 7 | 8 | public DataResponse(T result, long lastUpdated) { 9 | this.result = result; 10 | this.lastUpdated = lastUpdated; 11 | } 12 | 13 | public DataResponse(T result, long lastUpdated,String reportUrl ) { 14 | this.result = result; 15 | this.lastUpdated = lastUpdated; 16 | this.reportUrl = reportUrl; 17 | } 18 | 19 | public T getResult() { 20 | return result; 21 | } 22 | 23 | public long getLastUpdated() { 24 | return lastUpdated; 25 | } 26 | 27 | public String getReportUrl() { 28 | return reportUrl; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/GitSyncRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | public class GitSyncRequest extends BaseRequest { 6 | @NotNull 7 | private String repo; 8 | @NotNull 9 | private String branch; 10 | @NotNull 11 | private int historyDays; 12 | 13 | public String getRepo() { 14 | return repo; 15 | } 16 | 17 | public void setRepo(String repo) { 18 | this.repo = repo; 19 | } 20 | 21 | public String getBranch() { 22 | return branch; 23 | } 24 | 25 | public void setBranch(String branch) { 26 | this.branch = branch; 27 | } 28 | 29 | public int getHistoryDays() { return historyDays; } 30 | 31 | public void setHistoryDays(int historyDays) { this.historyDays = historyDays; } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/BinaryArtifactService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.BinaryArtifact; 5 | import com.capitalone.dashboard.model.DataResponse; 6 | import com.capitalone.dashboard.request.BinaryArtifactCreateRequest; 7 | import com.capitalone.dashboard.request.BinaryArtifactSearchRequest; 8 | 9 | public interface BinaryArtifactService { 10 | 11 | /** 12 | * Finds all of the Builds matching the specified request criteria. 13 | * 14 | * @param request search criteria 15 | * @return builds matching criteria 16 | */ 17 | DataResponse> search(BinaryArtifactSearchRequest request); 18 | 19 | String create(BinaryArtifactCreateRequest request) throws HygieiaException; 20 | } 21 | -------------------------------------------------------------------------------- /src/devops/.travis.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | ossrh 9 | ${env.OSSRH_USERNAME} 10 | ${env.OSSRH_PASSWORD} 11 | 12 | 13 | 14 | 15 | release 16 | 17 | ${env.GPG_KEYNAME} 18 | ${env.GPG_PASSPHRASE} 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/ldap/LdapLoginRequestFilter.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.ldap; 2 | 3 | import org.springframework.security.authentication.AuthenticationManager; 4 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 5 | 6 | import com.capitalone.dashboard.auth.AuthenticationResultHandler; 7 | 8 | public class LdapLoginRequestFilter extends UsernamePasswordAuthenticationFilter { 9 | 10 | public LdapLoginRequestFilter(String path, AuthenticationManager authenticationManager, AuthenticationResultHandler authenticationResultHandler) { 11 | super(); 12 | setAuthenticationSuccessHandler(authenticationResultHandler); 13 | setAuthenticationManager(authenticationManager); 14 | setFilterProcessesUrl(path); 15 | setAuthenticationDetailsSource(new LdapAuthenticationDetailsSource()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/TemplateRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import com.capitalone.dashboard.model.Service; 4 | import com.capitalone.dashboard.model.ServiceStatus; 5 | 6 | public class TemplateRequest extends BaseRequest { 7 | private ServiceStatus status; 8 | private String message; 9 | 10 | public ServiceStatus getStatus() { 11 | return status; 12 | } 13 | 14 | public void setStatus(ServiceStatus status) { 15 | this.status = status; 16 | } 17 | 18 | public String getMessage() { 19 | return message; 20 | } 21 | 22 | public void setMessage(String message) { 23 | this.message = message; 24 | } 25 | 26 | public Service update(Service service) { 27 | service.setStatus(status); 28 | service.setMessage(message); 29 | return service; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/capitalone/dashboard/auth/ldap/LdapLoginRequestFilterTest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.ldap; 2 | 3 | import static org.junit.Assert.assertNotNull; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.mockito.Mock; 8 | import org.mockito.runners.MockitoJUnitRunner; 9 | import org.springframework.security.authentication.AuthenticationManager; 10 | 11 | import com.capitalone.dashboard.auth.AuthenticationResultHandler; 12 | 13 | @RunWith(MockitoJUnitRunner.class) 14 | public class LdapLoginRequestFilterTest { 15 | 16 | @Mock 17 | private AuthenticationManager manager; 18 | 19 | @Mock 20 | private AuthenticationResultHandler authenticationResultHandler; 21 | 22 | @Test 23 | public void test() { 24 | LdapLoginRequestFilter filter = new LdapLoginRequestFilter("/login/ldap", manager, authenticationResultHandler); 25 | assertNotNull(filter); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/resources/userInfo/user.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "username" : "topopal", 4 | "authorities" : [ 5 | "ROLE_USER" 6 | ], 7 | "authType" : "STANDARD", 8 | "firstName" : "", 9 | "middleName" : "", 10 | "lastName" : "", 11 | "displayName" : "", 12 | "emailAddress" : "" 13 | }, 14 | { 15 | "username" : "testuser1", 16 | "authorities" : [ 17 | "ROLE_USER" 18 | ], 19 | "authType" : "STANDARD", 20 | "firstName" : "", 21 | "middleName" : "", 22 | "lastName" : "", 23 | "displayName" : "", 24 | "emailAddress" : "" 25 | }, 26 | { 27 | "username" : "testuser2", 28 | "authorities" : [ 29 | "ROLE_USER" 30 | ], 31 | "authType" : "STANDARD", 32 | "firstName" : "", 33 | "middleName" : "", 34 | "lastName" : "", 35 | "displayName" : "", 36 | "emailAddress" : "" 37 | } 38 | ] -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/util/PaginationHeaderUtility.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.util; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.http.HttpHeaders; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class PaginationHeaderUtility { 9 | 10 | public HttpHeaders buildPaginationHeaders(Page page) { 11 | HttpHeaders headers = new HttpHeaders(); 12 | headers.add("totalEntities", String.valueOf(page.getTotalElements())); 13 | headers.add("totalPages", String.valueOf(page.getTotalPages())); 14 | headers.add("lastPage", String.valueOf(page.isLast())); 15 | headers.add("pageSize", String.valueOf(page.getSize())); 16 | headers.add("currentPage", String.valueOf(page.getNumber())); 17 | headers.add("firstPage", String.valueOf(page.isFirst())); 18 | headers.add("nextPage", String.valueOf(page.hasNext())); 19 | 20 | return headers; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/UserInfoService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.security.core.GrantedAuthority; 6 | 7 | import com.capitalone.dashboard.model.AuthType; 8 | import com.capitalone.dashboard.model.UserInfo; 9 | 10 | public interface UserInfoService { 11 | 12 | Collection getAuthorities(String username, String firstName, String middleName, String lastName, String displayName, String emailAddress, AuthType authType); 13 | UserInfo getUserInfo(String username, String firstName, String middleName, String lastName, String displayName, String emailAddress, AuthType authType); 14 | Collection getUsers(); 15 | UserInfo promoteToAdmin(String username, AuthType authType); 16 | UserInfo demoteFromAdmin(String username, AuthType authType); 17 | boolean isUserValid(String userId, AuthType authType); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/rest/UserInfoController.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.rest; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import com.capitalone.dashboard.model.UserInfo; 11 | import com.capitalone.dashboard.service.UserInfoService; 12 | 13 | @RestController 14 | @RequestMapping("/users") 15 | public class UserInfoController { 16 | 17 | private UserInfoService userInfoService; 18 | 19 | @Autowired 20 | public UserInfoController(UserInfoService userInfoService) { 21 | this.userInfoService = userInfoService; 22 | } 23 | 24 | @RequestMapping(method = RequestMethod.GET) 25 | public Collection getUsers() { 26 | return userInfoService.getUsers(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/config/LoggingConfig.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Conditional; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import com.capitalone.dashboard.logging.DatabaseLoggingCondition; 8 | import com.capitalone.dashboard.logging.KeyValueLoggingCondition; 9 | import com.capitalone.dashboard.logging.KeyValueLoggingFilter; 10 | import com.capitalone.dashboard.logging.LoggingFilter; 11 | 12 | @Configuration 13 | public class LoggingConfig { 14 | 15 | @Bean 16 | @Conditional(KeyValueLoggingCondition.class) 17 | public KeyValueLoggingFilter splunkConnectionLoggingFilter() { 18 | return new KeyValueLoggingFilter(); 19 | } 20 | 21 | @Bean 22 | @Conditional(DatabaseLoggingCondition.class) 23 | public LoggingFilter loggingFilter() { 24 | return new LoggingFilter(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/PipelineResponseCommit.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class PipelineResponseCommit extends SCM { 7 | 8 | public PipelineResponseCommit(SCM scm) { 9 | super(scm); 10 | } 11 | 12 | Map processedTimestamps = new HashMap<>(); 13 | 14 | public void addNewPipelineProcessedTimestamp(PipelineStage stage, Long timestamp) { 15 | addNewPipelineProcessedTimestamp(stage.getName(), timestamp); 16 | } 17 | 18 | public void addNewPipelineProcessedTimestamp(String stageName, Long timestamp) { 19 | getProcessedTimestamps().put(stageName, timestamp); 20 | } 21 | 22 | public Map getProcessedTimestamps() { 23 | return processedTimestamps; 24 | } 25 | 26 | public void setProcessedTimestamps(Map processedTimestamps) { 27 | this.processedTimestamps = processedTimestamps; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/GitRequestRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import org.bson.types.ObjectId; 4 | 5 | import javax.validation.constraints.NotNull; 6 | 7 | public class GitRequestRequest extends BaseRequest { 8 | @NotNull 9 | private ObjectId componentId; 10 | private Integer numberOfDays; 11 | private ObjectId collectorItemId; 12 | 13 | 14 | public ObjectId getComponentId() { 15 | return componentId; 16 | } 17 | 18 | public void setComponentId(ObjectId componentId) { 19 | this.componentId = componentId; 20 | } 21 | 22 | public Integer getNumberOfDays() { 23 | return numberOfDays; 24 | } 25 | 26 | public void setNumberOfDays(Integer numberOfDays) { 27 | this.numberOfDays = numberOfDays; 28 | } 29 | 30 | public ObjectId getCollectorItemId() { return collectorItemId; } 31 | 32 | public void setCollectorItemId(ObjectId collectorItemId) { this.collectorItemId = collectorItemId; } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/CodeQualityService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.CodeQuality; 5 | import com.capitalone.dashboard.model.DataResponse; 6 | import com.capitalone.dashboard.request.CodeQualityCreateRequest; 7 | import com.capitalone.dashboard.request.CodeQualityRequest; 8 | 9 | public interface CodeQualityService { 10 | 11 | /** 12 | * Finds all of the CodeQuality data matching the specified request criteria. 13 | * 14 | * @param request search criteria 15 | * @return quality data matching criteria 16 | */ 17 | DataResponse> search(CodeQualityRequest request); 18 | DataResponse> getCodeQualityForWidget(CodeQualityRequest request); 19 | 20 | String create(CodeQualityCreateRequest request) throws HygieiaException; 21 | String createV2(CodeQualityCreateRequest request) throws HygieiaException; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/LibraryPolicyService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.LibraryPolicyResult; 5 | import com.capitalone.dashboard.request.LibraryPolicyRequest; 6 | 7 | import java.util.List; 8 | 9 | public interface LibraryPolicyService { 10 | 11 | /** 12 | * Finds all of the CodeQuality data matching the specified request criteria. 13 | * 14 | * @param request search criteria 15 | * @return quality data matching criteria 16 | */ 17 | DataResponse> search(LibraryPolicyRequest request); 18 | 19 | 20 | /** 21 | * Finds the most recent LibraryPolicy result for a specific collectorItemId 22 | * @param request collectorItemId componentId 23 | * @return data response of matching LibraryPolicy 24 | */ 25 | DataResponse> getLibraryPolicyForWidget(LibraryPolicyRequest request); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/BuildService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.Build; 5 | import com.capitalone.dashboard.response.BuildDataCreateResponse; 6 | import com.capitalone.dashboard.model.DataResponse; 7 | import com.capitalone.dashboard.request.BuildDataCreateRequest; 8 | import com.capitalone.dashboard.request.BuildSearchRequest; 9 | 10 | public interface BuildService { 11 | 12 | /** 13 | * Finds all of the Builds matching the specified request criteria. 14 | * 15 | * @param request search criteria 16 | * @return builds matching criteria 17 | */ 18 | DataResponse> search(BuildSearchRequest request); 19 | 20 | String create(BuildDataCreateRequest request) throws HygieiaException; 21 | String createV2(BuildDataCreateRequest request) throws HygieiaException; 22 | BuildDataCreateResponse createV3(BuildDataCreateRequest request) throws HygieiaException; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/AuthenticationResultHandler.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.security.core.Authentication; 11 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | public class AuthenticationResultHandler implements AuthenticationSuccessHandler { 16 | 17 | @Autowired 18 | private AuthenticationResponseService authenticationResponseService; 19 | 20 | @Override 21 | public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { 22 | authenticationResponseService.handle(response, authentication); 23 | } 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/resources/cloudinstance-9876543.json: -------------------------------------------------------------------------------- 1 | { 2 | "instanceId": "i-98765432", 3 | "accountNumber": "123456789", 4 | "instanceType": "m4.4xlarge", 5 | "imageId": "ami-abcd1234", 6 | "imageExpirationDate": 0, 7 | "imageApproved": false, 8 | "isMonitored": false, 9 | "privateDns": "ip-13-133-13-133.ec2.internal", 10 | "privateIp": "10.100.10.101", 11 | "publicDns": "", 12 | "subnetId": "subnet-abcd1235", 13 | "virtualNetworkId": "vpc-abcd1234", 14 | "age": 17, 15 | "isStopped": false, 16 | "isTagged": false, 17 | "cpuUtilization": 0.34450000000000003, 18 | "lastUpdatedDate": 1463109397378, 19 | "securityGroups": [ 20 | "DC-Client-ABC-DE-Ghijkl-ABCD1234", 21 | "AD-MyController-Only-DEV-SG-SecurityGroupDEV-ABCDEF1234" 22 | ], 23 | "tags": [ 24 | { 25 | "name": "MYEnvironment", 26 | "value": "MYSECONDENVIRONMENT" 27 | } 28 | ], 29 | "networkIn": 0.0, 30 | "networkOut": 0.0, 31 | "diskRead": 0.0, 32 | "diskWrite": 0.0, 33 | "rootDeviceName": "/dev/sda1", 34 | "autoScaleName": "NONE", 35 | "lastAction": "ADD" 36 | } -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/TestResultService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.DataResponse; 5 | import com.capitalone.dashboard.model.TestCreateRequest; 6 | import com.capitalone.dashboard.model.TestResult; 7 | import com.capitalone.dashboard.request.PerfTestDataCreateRequest; 8 | import com.capitalone.dashboard.request.TestDataCreateRequest; 9 | import com.capitalone.dashboard.request.TestResultRequest; 10 | 11 | public interface TestResultService { 12 | 13 | DataResponse> search(TestResultRequest request); 14 | String create(TestDataCreateRequest request) throws HygieiaException; 15 | String createV2(TestDataCreateRequest request) throws HygieiaException; 16 | String createPerf(PerfTestDataCreateRequest request) throws HygieiaException; 17 | String createPerfV2(PerfTestDataCreateRequest request) throws HygieiaException; 18 | String createTest(TestCreateRequest request) throws HygieiaException; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/ScoreCriteriaSettingsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.score.ScoreValueType; 4 | import com.capitalone.dashboard.model.score.settings.ScoreCriteriaSettings; 5 | import com.capitalone.dashboard.repository.ScoreCriteriaSettingsRepository; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class ScoreCriteriaSettingsServiceImpl implements ScoreCriteriaSettingsService{ 11 | 12 | private final ScoreCriteriaSettingsRepository scoreCriteriaSettingsRepository; 13 | 14 | @Autowired 15 | public ScoreCriteriaSettingsServiceImpl( 16 | ScoreCriteriaSettingsRepository scoreCriteriaSettingsRepository 17 | ) { 18 | this.scoreCriteriaSettingsRepository = scoreCriteriaSettingsRepository; 19 | } 20 | 21 | @Override 22 | public ScoreCriteriaSettings getScoreCriteriaSettingsByType(ScoreValueType type) { 23 | return this.scoreCriteriaSettingsRepository.findByType(type); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/deploy/Environment.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model.deploy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Environment { 7 | private final String name; 8 | private final String url; 9 | private final List units = new ArrayList<>(); 10 | 11 | public Environment(String name, String url) { 12 | this.name = name; 13 | this.url = url; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public String getUrl() { 21 | return url; 22 | } 23 | 24 | public List getUnits() { 25 | return units; 26 | } 27 | 28 | @Override 29 | public boolean equals(Object o) { 30 | if (this == o) return true; 31 | if (o == null || getClass() != o.getClass()) return false; 32 | 33 | Environment that = (Environment) o; 34 | return name.equals(that.name); 35 | } 36 | 37 | @Override 38 | public int hashCode() { 39 | return name.hashCode(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk11 4 | services: 5 | - docker 6 | 7 | branches: 8 | only: 9 | - "/^v[0-9]+\\.[0-9]+\\.[0-9]+.*$/" 10 | 11 | install: true 12 | 13 | before_script: 14 | - sudo chown -R $USER:$GROUP $TRAVIS_BUILD_DIR 15 | 16 | script: 17 | - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [[ "$TRAVIS_BRANCH" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then cp ./src/devops/release.sh . && ./release.sh; fi 18 | - export TAG=$TRAVIS_BRANCH 19 | - export IMAGE_NAME='hygieiadoc/api' 20 | - echo $IMAGE_NAME 21 | - echo $TAG 22 | - docker build -t $IMAGE_NAME . 23 | - docker tag $IMAGE_NAME $IMAGE_NAME:$TAG 24 | - docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS 25 | - docker push $IMAGE_NAME 26 | 27 | notifications: 28 | webhooks: 29 | urls: https://webhooks.gitter.im/e/48597b0f75dd571734bc 30 | on_success: always 31 | on_failure: always 32 | on_start: always 33 | email: 34 | recipients: 35 | - tapabrata.pal@capitalone.com 36 | - ragha.vema@capitalone.com 37 | - hygieia2@capitalone.com 38 | on_success: always 39 | on_failure: always -------------------------------------------------------------------------------- /src/devops/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/CollectorRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import com.capitalone.dashboard.model.Collector; 4 | import com.capitalone.dashboard.model.CollectorType; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * Created by yaf107 on 1/11/16. 10 | */ 11 | public class CollectorRequest extends BaseRequest { 12 | @NotNull 13 | private String name; 14 | @NotNull 15 | private CollectorType collectorType; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public CollectorType getCollectorType() { 26 | return collectorType; 27 | } 28 | 29 | public void setCollectorType(CollectorType collectorType) { 30 | this.collectorType = collectorType; 31 | } 32 | 33 | public Collector toCollector() { 34 | Collector collector = new Collector(); 35 | collector.setCollectorType(collectorType); 36 | collector.setName(name); 37 | return collector; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/request/AuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.request; 2 | 3 | import com.capitalone.dashboard.model.Authentication; 4 | 5 | import javax.validation.constraints.NotNull; 6 | 7 | public class AuthenticationRequest extends BaseRequest { 8 | 9 | @NotNull 10 | private String username; 11 | 12 | @NotNull 13 | private String password; 14 | 15 | public String getUsername() { 16 | return username; 17 | } 18 | 19 | public void setUsername(String username) { 20 | this.username = username; 21 | } 22 | 23 | public String getPassword() { 24 | return password; 25 | } 26 | 27 | public void setPassword(String password) { 28 | this.password = password; 29 | } 30 | 31 | public Authentication toAuthentication() { 32 | return new Authentication(username, password); 33 | } 34 | 35 | public Authentication copyTo(Authentication authentication) { 36 | Authentication updated = toAuthentication(); 37 | updated.setId(authentication.getId()); 38 | return updated; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/com/capitalone/dashboard/auth/AuthenticationResultHandlerTest.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth; 2 | 3 | import static org.mockito.Mockito.verify; 4 | 5 | import java.io.IOException; 6 | 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.mockito.InjectMocks; 13 | import org.mockito.Mock; 14 | import org.mockito.runners.MockitoJUnitRunner; 15 | import org.springframework.security.core.Authentication; 16 | 17 | @RunWith(MockitoJUnitRunner.class) 18 | public class AuthenticationResultHandlerTest { 19 | 20 | @Mock 21 | private AuthenticationResponseService responseService; 22 | 23 | @Mock 24 | private HttpServletResponse response; 25 | 26 | @Mock 27 | private Authentication auth; 28 | 29 | @InjectMocks 30 | private AuthenticationResultHandler handler; 31 | 32 | @Test 33 | public void testOnSucess() throws IOException, ServletException { 34 | handler.onAuthenticationSuccess(null, response, auth); 35 | 36 | verify(responseService).handle(response, auth); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/resources/com/capitalone/dashboard/rest/codequality.json: -------------------------------------------------------------------------------- 1 | { 2 | "hygieiaId": "56a57fde3b9b28e1ec3946e9", 3 | "timestamp": 1453686764000, 4 | "projectName": "DevOps Dashboard Core Library", 5 | "projectUrl": "http://localhost:9000/dashboard/index/1", 6 | "type": "StaticAnalysis", 7 | "projectVersion": "0.3.1-SNAPSHOT", 8 | "metrics": [ 9 | { 10 | "name": "ncloc", 11 | "value": 1974.0, 12 | "formattedValue": "1,974", 13 | "status": "Ok" 14 | }, 15 | { 16 | "name": "violations", 17 | "value": 56.0, 18 | "formattedValue": "56", 19 | "status": "Ok" 20 | }, 21 | { 22 | "name": "blocker_violations", 23 | "value": 0.0, 24 | "formattedValue": "0", 25 | "status": "Ok" 26 | }, 27 | { 28 | "name": "critical_violations", 29 | "value": 3.0, 30 | "formattedValue": "3", 31 | "status": "Ok" 32 | }, 33 | { 34 | "name": "major_violations", 35 | "value": 5.0, 36 | "formattedValue": "5", 37 | "status": "Ok" 38 | }, 39 | { 40 | "name": "sqale_index", 41 | "value": 432.0, 42 | "formattedValue": "7h 12min", 43 | "status": "Ok" 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /src/test/resources/dashboardRemoteRequests/0-Remote-Update-All-Empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaData": 3 | { 4 | "applicationName":"TestAudit", 5 | "componentName":"TestAudit", 6 | "owner": 7 | { 8 | "authType":"STANDARD", 9 | "username":"topopal" 10 | }, 11 | "owners": 12 | [ 13 | { 14 | "authType":"STANDARD", 15 | "username":"topopal" 16 | }, 17 | { 18 | "authType":"STANDARD", 19 | "username":"topopal" 20 | }, 21 | { 22 | "authType":"STANDARD", 23 | "username":"testuser1" 24 | }, 25 | { 26 | "authType":"STANDARD", 27 | "username":"testuser1" 28 | }, 29 | { 30 | "authType":"STANDARD", 31 | "username":"testuser2" 32 | } 33 | ], 34 | "template":"CapOne", 35 | "title":"TestSSA", 36 | "type":"Team" 37 | }, 38 | "codeRepoEntries" : [], 39 | "functionalTestEntries" : [], 40 | "buildEntries" : [], 41 | "libraryScanEntries": [], 42 | "securityScanEntries" : [], 43 | "staticCodeEntries" : [], 44 | "featureEntries" : [], 45 | "deploymentEntries" : [], 46 | "infraStructureScanEntries": [] 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/rest/LogAnalysisController.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.rest; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.LogAnalysis; 5 | import com.capitalone.dashboard.request.LogAnalysisSearchRequest; 6 | import com.capitalone.dashboard.service.LogAnalysisService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.validation.Valid; 13 | 14 | @RestController 15 | public class LogAnalysisController { 16 | 17 | private final LogAnalysisService logAnalysisService; 18 | 19 | @Autowired 20 | public LogAnalysisController(LogAnalysisService logAnalysisService) { 21 | this.logAnalysisService = logAnalysisService; 22 | } 23 | 24 | @RequestMapping(value="/loganalysis", method = RequestMethod.GET) 25 | public DataResponse> findAllLogAnalysisJobs(@Valid LogAnalysisSearchRequest request){ 26 | return this.logAnalysisService.search(request); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/CommitService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.Commit; 5 | import com.capitalone.dashboard.model.DataResponse; 6 | import com.capitalone.dashboard.request.CommitRequest; 7 | import org.json.simple.JSONObject; 8 | import org.json.simple.parser.ParseException; 9 | 10 | import java.util.List; 11 | 12 | public interface CommitService { 13 | 14 | /** 15 | * Finds all of the Commits matching the specified request criteria. 16 | * 17 | * @param request search criteria 18 | * @return commits matching criteria 19 | */ 20 | DataResponse> search(CommitRequest request); 21 | 22 | String createFromGitHubv3(JSONObject request) throws ParseException, HygieiaException; 23 | 24 | List getCommitsBySha (String scmRevisionNumber); 25 | 26 | /** 27 | * Finds all of the Commits for a specific collectorItem 28 | * 29 | * @param request componentId collectorItemId 30 | * @return commits matching criteria 31 | */ 32 | DataResponse> getCommitsForWidget(CommitRequest request); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/webhook/github/GithubWebHookAuthServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.webhook.github; 2 | 3 | import com.capitalone.dashboard.model.UserRole; 4 | import org.apache.commons.logging.Log; 5 | import org.apache.commons.logging.LogFactory; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import java.util.Collections; 13 | 14 | @Component 15 | public class GithubWebHookAuthServiceImpl implements GithubWebHookAuthService { 16 | private static final Log LOG = LogFactory.getLog(GithubWebHookAuthServiceImpl.class); 17 | 18 | @Override 19 | public Authentication getAuthentication(HttpServletRequest request) { 20 | LOG.info("Pre-Authenticating the api request with user 'githubWebHookDummyUser' "); 21 | 22 | return new PreAuthenticatedAuthenticationToken("githubWebHookDummyUser", null, Collections.singleton(new SimpleGrantedAuthority(UserRole.ROLE_API.name()))); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/AuthenticationUtil.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.security.core.context.SecurityContextHolder; 5 | 6 | import com.capitalone.dashboard.model.AuthType; 7 | 8 | public class AuthenticationUtil { 9 | 10 | public static final String AUTH_TYPE = "auth_type"; 11 | 12 | public static String getUsernameFromContext() { 13 | Authentication authentication = getAuthentication(); 14 | if (authentication != null) { 15 | return authentication.getName(); 16 | } 17 | 18 | return null; 19 | } 20 | 21 | public static AuthType getAuthTypeFromContext() { 22 | Authentication authentication = getAuthentication(); 23 | if (authentication != null && authentication.getDetails() instanceof String) { 24 | return AuthType.valueOf((String)authentication.getDetails()); 25 | } else if (authentication != null && authentication.getDetails() instanceof AuthType) { 26 | return (AuthType)authentication.getDetails(); 27 | } 28 | 29 | return null; 30 | } 31 | 32 | private static Authentication getAuthentication() { 33 | return SecurityContextHolder.getContext().getAuthentication(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/auth/standard/StandardAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.auth.standard; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.authentication.AuthenticationProvider; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.capitalone.dashboard.service.AuthenticationService; 10 | 11 | @Component 12 | public class StandardAuthenticationProvider implements AuthenticationProvider { 13 | 14 | private final AuthenticationService authService; 15 | 16 | @Autowired 17 | public StandardAuthenticationProvider(AuthenticationService authService) { 18 | this.authService = authService; 19 | } 20 | 21 | @Override 22 | public Authentication authenticate(Authentication authentication) throws AuthenticationException { 23 | return authService.authenticate(authentication.getName(), (String)authentication.getCredentials()); 24 | } 25 | 26 | @Override 27 | public boolean supports(Class authentication) { 28 | return StandardAuthenticationToken.class.isAssignableFrom(authentication); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/webhook/settings/JenkinsBuildWebHookSettings.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.webhook.settings; 2 | 3 | import java.util.List; 4 | 5 | public class JenkinsBuildWebHookSettings { 6 | 7 | private List excludeCodeReposInBuild; 8 | 9 | private boolean enableFilterLibraryRepos; 10 | 11 | private int excludeLibraryRepoThreshold; 12 | 13 | public List getExcludeCodeReposInBuild() { 14 | return excludeCodeReposInBuild; 15 | } 16 | 17 | public void setExcludeCodeReposInBuild(List excludeCodeReposInBuild) { 18 | this.excludeCodeReposInBuild = excludeCodeReposInBuild; 19 | } 20 | 21 | public boolean isEnableFilterLibraryRepos() { 22 | return enableFilterLibraryRepos; 23 | } 24 | 25 | public void setEnableFilterLibraryRepos(boolean enableFilterLibraryRepos) { 26 | this.enableFilterLibraryRepos = enableFilterLibraryRepos; 27 | } 28 | 29 | public int getExcludeLibraryRepoThreshold() { 30 | return excludeLibraryRepoThreshold; 31 | } 32 | 33 | public void setExcludeLibraryRepoThreshold(int excludeLibraryRepoThreshold) { 34 | this.excludeLibraryRepoThreshold = excludeLibraryRepoThreshold; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/model/monitor/MonitorProxySettings.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.model.monitor; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | @ConfigurationProperties("monitor.proxy") 8 | public class MonitorProxySettings { 9 | 10 | private String username; 11 | private String password; 12 | private String type; 13 | private String host; 14 | private int port; 15 | 16 | public String getUsername() { 17 | return username; 18 | } 19 | 20 | public void setUsername(String username) { 21 | this.username = username; 22 | } 23 | 24 | public String getPassword() { 25 | return password; 26 | } 27 | 28 | public void setPassword(String password) { 29 | this.password = password; 30 | } 31 | 32 | public String getType() { 33 | return type; 34 | } 35 | 36 | public void setType(String type) { 37 | this.type = type; 38 | } 39 | 40 | public String getHost() { 41 | return host; 42 | } 43 | 44 | public void setHost(String host) { 45 | this.host = host; 46 | } 47 | 48 | public int getPort() { 49 | return port; 50 | } 51 | 52 | public void setPort(int port) { 53 | this.port = port; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/rest/ScoreController.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.rest; 2 | 3 | import com.capitalone.dashboard.model.DataResponse; 4 | import com.capitalone.dashboard.model.score.ScoreMetric; 5 | import com.capitalone.dashboard.service.ScoreService; 6 | import org.bson.types.ObjectId; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; 13 | import static org.springframework.web.bind.annotation.RequestMethod.GET; 14 | 15 | @RestController 16 | public class ScoreController { 17 | 18 | private final ScoreService scoreService; 19 | 20 | @Autowired 21 | public ScoreController(ScoreService scoreService) { 22 | this.scoreService = scoreService; 23 | } 24 | 25 | @RequestMapping(value = "/score/metric/{dashboardId}", method = GET, produces = APPLICATION_JSON_VALUE) 26 | public DataResponse scoreMetric(@PathVariable ObjectId dashboardId) { 27 | return scoreService.getScoreMetric(dashboardId); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/ScoreDashboardService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.model.CollectorItem; 4 | import com.capitalone.dashboard.model.Dashboard; 5 | 6 | public interface ScoreDashboardService { 7 | 8 | /** 9 | * Add Score Collector Item for dashboard if score is enabled 10 | * 11 | * @param dashboard Dashboard Model 12 | * @return CollectorItem for score 13 | */ 14 | CollectorItem addScoreForDashboardIfScoreEnabled(Dashboard dashboard); 15 | 16 | /** 17 | * Edit Score for dashboard 18 | * Enable/Disable score for a existing dashboard 19 | * 20 | * @param prevSettings Dashboard Model 21 | * @return CollectorItem for score 22 | */ 23 | CollectorItem editScoreForDashboard(Dashboard prevSettings); 24 | 25 | /** 26 | * Add Score Collector Item for dashboard 27 | * 28 | * @param dashboard Dashboard Model 29 | * @return CollectorItem for score 30 | */ 31 | CollectorItem addScoreForDashboard(Dashboard dashboard); 32 | 33 | /** 34 | * Disable Score for dashboard 35 | * 36 | * @param dashboard Dashboard Model 37 | * @return CollectorItem for score 38 | */ 39 | CollectorItem disableScoreForDashboard(Dashboard dashboard); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/capitalone/dashboard/service/TemplateService.java: -------------------------------------------------------------------------------- 1 | package com.capitalone.dashboard.service; 2 | 3 | import com.capitalone.dashboard.misc.HygieiaException; 4 | import com.capitalone.dashboard.model.Template; 5 | import org.bson.types.ObjectId; 6 | 7 | 8 | public interface TemplateService { 9 | 10 | /** 11 | * Fetches all registered templates, sorted by title. 12 | * 13 | * @return all templates 14 | */ 15 | Iterable