diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b27c6c6f..34048c8a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,6 +22,8 @@ jobs: Init: needs: [Wokflow-Queue] runs-on: ubuntu-20.04 + outputs: + Version: ${{ steps.setVariables.outputs.version }} steps: - uses: actions/checkout@v2 with: @@ -33,13 +35,14 @@ jobs: - name: Bump version if: github.ref == 'refs/heads/edi-foundation-integration' + id: setVariables run: | sudo apt update sudo apt install bumpversion bumpversion patch new_version=`cat VERSION` echo "New version is: $new_version" - + echo "version=$new_version" >> $GITHUB_OUTPUT git config --global user.name "CI Build" git config --global user.email "ci.build@philips.com" git commit -am "Bump version $new_version" @@ -93,23 +96,24 @@ jobs: uses: actions/checkout@v2 - name: blackduck scan - run: powershell -ExecutionPolicy RemoteSigned -NoExit -File ${{ github.workspace }}\Build\PS\Invoke-BlackduckDetect.ps1 -SourcePath ${{ github.workspace }} - + run: powershell -ExecutionPolicy RemoteSigned -NoExit -File ${{ github.workspace }}\Build\PS\Invoke-BlackduckDetect.ps1 -SourcePath ${{ github.workspace }} -ApiToken ${{ secrets.BLACKDUCK_TOKEN }} + Fortify: needs: [Init] - runs-on: builder_blr + runs-on: builder_blr_2 steps: - name: checkout uses: actions/checkout@v2 - name: Fortify scan - run: powershell -ExecutionPolicy RemoteSigned -NoExit -File ${{ github.workspace }}\build\ps\Invoke-FortifyScan.ps1 + run: powershell -ExecutionPolicy RemoteSigned -NoExit -File ${{ github.workspace }}\build\ps\Invoke-FortifyScan.ps1 -PublishAuthToken ${{ secrets.FORTIFY_TOKEN }} + Build: needs: [Init] runs-on: ubuntu-20.04 outputs: - oauth2proxyPRTag: ${{ steps.setVariables.outputs.alphaTag }} + oauth2proxyPRTag: ${{ steps.setVariables.outputs.prTag }} oauth2proxyCITag: ${{ steps.setVariables.outputs.betaTag }} steps: - uses: actions/checkout@v2 @@ -135,15 +139,14 @@ jobs: - name: Set env variables run: | - new_version=`cat VERSION` - alpha_tag="${new_version}-alpha" + new_version=${{ needs.Init.outputs.Version }} + pr_tag="PR-${{ github.run_id }}" beta_tag="${new_version}-beta" echo "New version is: $new_version" echo "VERSION=$new_version" >> "$GITHUB_ENV" echo "CI_IMAGE=${{ env.HSDP_DOCKER_REGISTRY }}/edi-foundation-oauth2-proxy:${beta_tag}" >> "$GITHUB_ENV" - echo "PR_IMAGE=${{ env.HSDP_DOCKER_REGISTRY }}/edi-foundation-oauth2-proxy:${alpha_tag}" >> "$GITHUB_ENV" - echo "CI_LATEST_IMAGE=${{ env.HSDP_DOCKER_REGISTRY }}/edi-foundation-oauth2-proxy:latest" >> "$GITHUB_ENV" - echo "alphaTag=${alpha_tag}" >> $GITHUB_OUTPUT + echo "PR_IMAGE=${{ env.HSDP_DOCKER_REGISTRY }}/edi-foundation-oauth2-proxy:${pr_tag}" >> "$GITHUB_ENV" + echo "prTag=${pr_tag}" >> $GITHUB_OUTPUT echo "betaTag=${beta_tag}" >> $GITHUB_OUTPUT - name: Docker Build @@ -156,8 +159,7 @@ jobs: - name: Docker tag run: | - docker tag '${{ secrets.DOCKER_REPO }}'/oauth2-proxy:latest ${{ env.CI_IMAGE }} - docker tag ${{ env.CI_IMAGE }} ${{ env.PR_IMAGE }} + docker tag '${{ secrets.DOCKER_REPO }}'/oauth2-proxy:latest ${{ env.PR_IMAGE }} - name: PR Image Docker Push if: github.event_name == 'pull_request' @@ -167,8 +169,7 @@ jobs: - name: Docker Push if: github.ref == 'refs/heads/edi-foundation-integration' run: | - docker tag ${{ env.CI_IMAGE }} ${{ env.CI_LATEST_IMAGE }} - docker push ${{ env.CI_LATEST_IMAGE }} + docker tag ${{ env.PR_IMAGE }} ${{ env.CI_IMAGE }} docker push ${{ env.CI_IMAGE }} PR_Deploy_Test_HDS_AUTH_GATEWAY: @@ -219,6 +220,9 @@ jobs: - name: Set env variables id: setVariables run: | + sudo apt update + sudo apt install bumpversion + bumpversion patch new_version=`cat VERSION` echo "New version is: $new_version" echo "CI_IMAGE=${{ env.HSDP_DOCKER_REGISTRY }}/edi-foundation-oauth2-proxy:${new_version}-beta" >> "$GITHUB_ENV" diff --git a/build/ps/Invoke-BlackDuckDetect.ps1 b/build/ps/Invoke-BlackDuckDetect.ps1 index d9fd1fd2..04c541d1 100644 --- a/build/ps/Invoke-BlackDuckDetect.ps1 +++ b/build/ps/Invoke-BlackDuckDetect.ps1 @@ -3,7 +3,7 @@ param( $ProjectVersionName = "1.0", $SourcePath, $BlackduckUrl = "https://blackduck.philips.com/", - $ApiToken = "OWFkOWM0NGMtM2FlMy00ODFiLThjMTctM2I1OTdkMTY2MTQ2OmNlMGI4NmNhLWRjMzAtNGU0Yy04NTIwLWEzZDI5NDFlNjdkMg==", + $ApiToken, $ProxyHost = "apac.zscaler.philips.com", $ProxyPort = "10015", $ProxyIgnoreHosts = "blackduck.philips.com" diff --git a/build/ps/Invoke-FortifyScan.ps1 b/build/ps/Invoke-FortifyScan.ps1 index d21a55bb..844860f0 100644 --- a/build/ps/Invoke-FortifyScan.ps1 +++ b/build/ps/Invoke-FortifyScan.ps1 @@ -2,10 +2,12 @@ param( $FortifyProjectId = "edifoundation-oauth2proxy", $FortifyVersionId = "Main", $FortifyBuildId = "fortify_fl", - $FortifyFprPath = "$PSScriptRoot\$FortifyProjectId.$FortifyVersionId.fpr", + $FortifyFprPath = "$PSScriptRoot\$FortifyProjectId.fpr", $PublishURL = "https://fortify.philips.com/ssc", - $PublishAuthToken = "785de478-dc2d-4829-959c-ea5cb8cd1adc", - $RepositoryRoot = "$PSScriptRoot\..\..\" + [string]$PublishAuthToken, + $RepositoryRoot = "$PSScriptRoot\..\..\", + $Sourceanalyzer = "C:\Program Files\Fortify\Fortify_SCA_and_Apps_22.1.1\bin\sourceanalyzer.exe", + $FortifyClient = "C:\Program Files\Fortify\Fortify_SCA_and_Apps_22.1.1\bin\fortifyclient.bat" ) function Invoke-VswhereDownload ( @@ -21,11 +23,13 @@ function Invoke-VswhereDownload ( try { $RepositoryRoot = [System.IO.Path]::GetFullPath($RepositoryRoot) + & sourceanalyzer -b $FortifyBuildId -clean -logfile "$PSScriptRoot\fortify-clean.txt" - & sourceanalyzer -Xmx8G -b $FortifyBuildId "$RepositoryRoot\contrib" + & sourceanalyzer -Xmx8G -b $FortifyBuildId -gopath $RepositoryRoot -goroot $RepositoryRoot "$RepositoryRoot\**\*.go" & sourceanalyzer -b $FortifyBuildId -show-files - & sourceanalyzer -Xmx8G -b $FortifyBuildId -Dcom.fortify.sca.Phase0HigherOrder.Languages=javascript,typescript -scan -f $FortifyFprPath -logfile "$PSScriptRoot\fortify-scan.txt" + #& sourceanalyzer -Xmx8G -b $FortifyBuildId -Dcom.fortify.sca.Phase0HigherOrder.Languages=go -scan -f $FortifyFprPath -logfile "$PSScriptRoot\fortify-scan.txt" + & sourceanalyzer -Xmx8G -b $FortifyBuildId -logfile "$PSScriptRoot\fortify-scan.txt" -scan -f $FortifyFprPath #Upload fpr reports to fortify server Write-Output "Uploading '$FortifyFprPath' of '$FortifyProjectId' with version '$FortifyVersionId' to '$PublishURL'" diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..fc436707 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,7 @@ +sonar.projectKey=EDI-hds-oauth2-proxy +sonar.projectName=EDI-hds-oauth2-proxy +sonar.go.coverage.reportPaths=coverage.out +sonar.sources=. +sonar.exclusions=**/*_test.go +sonar.tests=. +sonar.test.inclusions=**/*_test.go \ No newline at end of file