diff --git a/Dockerfile b/Dockerfile index ca0c348f46049c905865c3c5029f36ca707a0049..f60c655eac6c818e269f970ce8c4f617b3a00936 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,23 @@ -ARG BASE_REGISTRY=registry1.dso.mil/ironbank -ARG BASE_IMAGE=redhat/openjdk/openjdk8 -ARG BASE_TAG=latest +ARG BASE_REGISTRY=registry1.dso.mil +ARG BASE_IMAGE=ironbank/redhat/openjdk/openjdk8 +ARG BASE_TAG=1.8.0 -FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} - -USER 0 +FROM hygieiadoc/githubscmcollector:v3.2.0 as builder -RUN dnf upgrade -y && \ - dnf clean all && \ - rm -rf /var/cache/dnf +FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} -RUN mkdir -p /app/logs \ - mkdir -p /app/config +EXPOSE 8080 -RUN chown -R 1001:1001 /app -RUN chmod 755 /app +ENV PROP_FILE /hygieia/config/application.properties -WORKDIR /app +WORKDIR /hygieia +COPY scripts/properties-builder.sh /hygieia/ +COPY --from=builder /hygieia/ /hygieia/ USER 1001 -COPY ./gitlab-scm-collector.jar . -COPY ./scripts/collector-launch.sh ./scripts/collector-launch.sh -CMD ./scripts/collector-launch.sh +CMD ./properties-builder.sh &&\ + java -Djava.security.egd=file:/dev/./urandom -jar *.jar --spring.config.location=$PROP_FILE HEALTHCHECK NONE diff --git a/config/boiler.application.properties b/config/boiler.application.properties deleted file mode 100644 index 2a2248308fb3ae25a1b5517daa639afe010bd0c5..0000000000000000000000000000000000000000 --- a/config/boiler.application.properties +++ /dev/null @@ -1,51 +0,0 @@ - # Database Name - dbname=dashboarddb - - # Database HostName - default is localhost - dbhost=localhost - - # Database Port - default is 27017 - dbport=27017 - - # MongoDB replicaset - dbreplicaset=[false if you are not using MongoDB replicaset] - dbhostport=[host1:port1,host2:port2,host3:port3] - - # Database Username - default is blank - dbusername= - - # Database Password - default is blank - dbpassword= - - # Logging File location - logging.file=./logs/gitlab.log - - #Collector schedule (required) - gitlab.cron=0 0/1 * * * * - - #Gitlab host (optional, defaults to 'gitlab.com') - gitlab.host=gitlab.company.com - - #Gitlab protocol (optional, defaults to 'http') - gitlab.protocol=http - - #If enabled, dashboard URL configured in UI follows this example :/// - #gitlab.useProjectId (optional, defaults to false) - - #Gitlab port (optional, defaults to protocol default port) - gitlab.port=80 - - #Gitlab path (optional, if your instance of gitlab requires a path) - gitlab.path=/gitlab/resides/here - - #If your instance of Gitlab is using a self-signed certificate, set to true, default is false - gitlab.selfSignedCertificate=false - - #Gitlab API Token (required, user token the collector will use by default, can be overridden on a per repo basis from the UI. API token provided by Gitlab) - gitlab.apiToken= - - #Maximum number of previous days from current date, when fetching commits - gitlab.commitThresholdDays=15 - - # Gitlab key for private repos - gitlab.key= diff --git a/hardening_manifest.yaml b/hardening_manifest.yaml index c4c9471657d4ef1e106e24b7e1dbac5aef351800..6489573dfda9e8d636cecfb7b826af5ef2243414 100644 --- a/hardening_manifest.yaml +++ b/hardening_manifest.yaml @@ -8,7 +8,7 @@ name: "opensource/hygieia/hygieia-scm-gitlab-collector" # The most specific version should be the first tag and will be shown # on ironbank.dsop.io tags: -- "v3.1.0" +- "v3.2.0" - "latest" # Build args passed to Dockerfile ARGs @@ -27,7 +27,7 @@ labels: org.opencontainers.image.url: "https://github.com/bitnami/bitnami-docker-elasticsearch-exporter" ## Name of the distributing entity, organization or individual org.opencontainers.image.vendor: "hygieia" - org.opencontainers.image.version: "v3.1.0" + org.opencontainers.image.version: "v3.2.0" ## Keywords to help with search (ex. "cicd,gitops,golang") mil.dso.ironbank.image.keywords: "configmap,hygieia,gitlab,collector" ## This value can be "opensource" or "commercial" @@ -37,17 +37,12 @@ labels: # List of resources to make available to the offline build context resources: - -- filename: gitlab-scm-collector.jar - url: https://repo.maven.apache.org/maven2/com/capitalone/dashboard/gitlab-scm-collector/3.1.0/gitlab-scm-collector-3.1.0.jar - validation: - type: sha256 - value: 57f53acb6edaae368291050af44f1662b1ba80a891b58780535291c36f5eadbc - +- url: docker://docker.io/hygieiadoc/githubscmcollector@sha256:eed4624f71d52dc5fc9c4ff98bf48e10c54f647710a86629164f148e7427a0b5 + tag: hygieiadoc/githubscmcollector:v3.2.0 # List of project maintainers maintainers: -- name: "Chris Byrd" - username: "crbcos" - email: "chris.byrd@parsons.com" +- name: "Olga Ojjeh" + username: "olga" + email: "olga@alphabravo.io" cht_member: true diff --git a/renovate.json b/renovate.json index cd820da2498dfa66be542a1077da2633d3335abe..33d75449984b1351534072aaf9620275237a27ac 100644 --- a/renovate.json +++ b/renovate.json @@ -1,37 +1,30 @@ { - "assignees": [ - "@chris.byrd" - ], - "baseBranches": [ - "development" - ], - "regexManagers": [ - { - "matchStrings": [ - "version=\"(?.*?)\"" - ], - "depNameTemplate": "hygieia/hygieia-scm-gitlab-collector", - "datasourceTemplate": "docker" - }, - { - "fileMatch": [ - "^hardening_manifest.yaml$" - ], - "matchStrings": [ - "org\\.opencontainers\\.image\\.version:\\s+\"(?.+?)\"" - ], - "depNameTemplate": "hygieia/hygieia-scm-gitlab-collector:v3.1.0", - "datasourceTemplate": "docker" - }, - { - "fileMatch": [ - "^hardening_manifest.yaml$" - ], - "matchStrings": [ - "tags:\\s+-\\s+\"(?.+?)\"" - ], - "depNameTemplate": "hygieia/hygieia-scm-gitlab-collector:v3.1.0", - "datasourceTemplate": "docker" - } - ] - } + "assignees": [ + "@olga" + ], + "baseBranches": [ + "development" + ], + "regexManagers": [ + { + "fileMatch": [ + "^hardening_manifest.yaml$" + ], + "matchStrings": [ + "org\\.opencontainers\\.image\\.version:\\s+\"(?.+?)\"" + ], + "depNameTemplate": "hygieiadoc/githubscmcollector", + "datasourceTemplate": "docker" + }, + { + "fileMatch": [ + "^hardening_manifest.yaml$" + ], + "matchStrings": [ + "tags:\\s+-\\s+\"(?.+?)\"" + ], + "depNameTemplate": "hygieiadoc/githubscmcollector", + "datasourceTemplate": "docker" + } + ] +} diff --git a/scripts/collector-launch.sh b/scripts/collector-launch.sh deleted file mode 100755 index ccbd6bf03fdb4e4c3b8a5b84711b80e185a8e5af..0000000000000000000000000000000000000000 --- a/scripts/collector-launch.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash - -if [ "$SKIP_PROPERTIES_BUILDER" = true ]; then - echo "Skipping properties builder" - java -jar gitlab-scm-collector.jar --spring.config.name=gitlab --spring.config.location=${PROP_FILE} - exit 0 -fi - -if ! [ "$PROP_FILE" ]; then - echo "PROP_FILE not set. Defaulting to /app/config/application.properties" - export PROP_FILE=/app/config/application.properties - sudo touch $PROP_FILE -fi - -if [ "$GITLAB_USE_PROJECT_ID" ]; then - echo "GITLAB_USE_PROJECT_ID set." - export GITLAB_USE_PROJECT_ID_TITLE=gitlab.useProjectId -else - echo "GITLAB_USE_PROJECT_ID not set. Skipping." - export GITLAB_USE_PROJECT_ID_TITLE=\#gitlab.useProjectId -fi - -if ! [ "DB_NAME" ]; then - echo "DB_NAME not set. Defaulting to empty string." - export DB_NAME="" -fi - -if ! [ "$DB_HOST" ]; then - echo "DB_HOST not set. Defaulting to localhost" - export DB_HOST=localhost -fi - -if ! [ "$DB_PORT" ]; then - echo "DB_PORT not set. Defaulting to 27017" - export DB_PORT=27017 -fi - -if ! [ "$DB_REPLICA_SET" ]; then - echo "DB_REPLICA_SET not set. Defaulting to false." - export DB_REPLICA_SET=false -fi - -if ! [ "$DB_HOST_PORT" ]; then - echo "DB_HOST_PORT not set. Defaulting to empty string." - export DB_HOST_PORT="" -fi - -if ! [ "$DB_USERNAME" ]; then - echo "DB_USERNAME not set. Defaulting to empty string." - export DB_USER_NAME="" -fi - -if ! [ "$DB_PASSWORD" ]; then - echo "DB_PASSWORD not set. Defaulting to empty string." - export DB_PASSWORD="" -fi - -if ! [ "$LOGS_PATH" ]; then - echo "LOGS_PATH not set. Defaulting to /app/logs/gitlab.log." - export LOGS_PATH="/app/logs" -fi - -if ! [ "$COLLECTOR_CRON" ]; then - echo "COLLECTOR_CRON not set. Defaulting to 0 0/1 * * * *" - export COLLECTOR_CRON="0 0/1 * * * *" -fi - -if ! [ "$GITLAB_HOST" ]; then - echo "GITLAB_HOST not set. Defaulting to gitlab.company.com" - export GITLAB_HOST=gitlab.company.com -fi - -if ! [ "$GITLAB_PROTOCOL" ]; then - echo "GITLAB_PROTOCOL not set. Defaulting to http" - export GITLAB_PROTOCOL=http -fi - -if ! [ "$GITLAB_PORT" ]; then - echo "GITLAB_PORT not set. Defaulting to 80" - export GITLAB_PORT=80 -fi - -if ! [ "$GITLAB_PATH" ]; then - echo "GITLAB_PATH not set. Defaulting to empty string" - export GITLAB_PATH="" -fi - -if ! [ "$GITLAB_SELF_SIGNED_CERT" ]; then - echo "GITLAB_SELF_SIGNED_CERT not set. Defaulting to false" - export GITLAB_SELF_SIGNED_CERT=false -fi - -if ! [ "$GITLAB_API_TOKEN" ]; then - echo "GITLAB_API_TOKEN not set. Value is required." - exit 0 -fi - -if ! [ "$GITLAB_COMMIT_THREASHOLD_DAYS" ]; then - echo "GITLAB_COMMIT_THREASHOLD_DAYS not set. Defaulting to 15 days." - export GITLAB_COMMIT_THREASHOLD_DAYS=15 -fi - -if ! [ "$GITLAB_KEY" ]; then - echo "GITLAB_KEY not set. Defaulting to empty string" - export GITLAB_KEY="" -fi - -cat > $PROP_FILE <:/// - (optional, defaults to false) -$GITLAB_USE_PROJECT_ID_TITLE=$GITLAB_USE_PROJECT_ID - -#Gitlab port (optional, defaults to protocol default port) - 80 -gitlab.port=$GITLAB_PORT - -#Gitlab path (optional, if your instance of gitlab requires a path) - /gitlab/resides/here -gitlab.path=$GITLAB_PATH - -#If your instance of Gitlab is using a self-signed certificate, set to true, default is false - false -gitlab.selfSignedCertificate=$GITLAB_SELF_SIGNED_CERT - -#Gitlab API Token (required, user token the collector will use by default, can be overridden on a per repo basis from the UI. API token provided by Gitlab) -gitlab.apiToken=$GITLAB_API_TOKEN - -#Maximum number of previous days from current date, when fetching commits - 15 -gitlab.commitThresholdDays=$GITLAB_COMMIT_THREASHOLD_DAYS - -# Gitlab key for private repos -gitlab.key=$GITLAB_KEY - -EOF - -echo " -=========================================== -Properties file created: $PROP_FILE -Note: passwords hidden -=========================================== -`cat $PROP_FILE |egrep -vi 'password|Credentials'` -" - -java -jar gitlab-scm-collector.jar --spring.config.name=gitlab --spring.config.location=${PROP_FILE} \ No newline at end of file diff --git a/scripts/properties-builder.sh b/scripts/properties-builder.sh new file mode 100644 index 0000000000000000000000000000000000000000..f5b0e5c83bee2783b15039fd45cffda927ca1569 --- /dev/null +++ b/scripts/properties-builder.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +if [ "$SKIP_PROPERTIES_BUILDER" = true ]; then + echo "Skipping properties builder" + exit 0 +fi + +if [ "$MONGO_PORT" != "" ]; then + # Sample: MONGO_PORT=tcp://172.17.0.20:27017 + MONGODB_HOST=`echo $MONGO_PORT|sed 's;.*://\([^:]*\):\(.*\);\1;'` + MONGODB_PORT=`echo $MONGO_PORT|sed 's;.*://\([^:]*\):\(.*\);\2;'` +else + env + echo "ERROR: MONGO_PORT not defined" + exit 1 +fi + +echo "MONGODB_HOST: $MONGODB_HOST" +echo "MONGODB_PORT: $MONGODB_PORT" + +cat > $PROP_FILE <