diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..53d6df76 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,84 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- main + +pool: + vmImage: ubuntu-latest +steps: + +- task: Maven@4 + inputs: + mavenPomFile: 'pom.xml' + goals: 'package' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + javaHomeOption: 'JDKVersion' + mavenVersionOption: 'Default' + mavenAuthenticateFeed: false + effectivePomSkip: false + sonarQubeRunAnalysis: false + +- task: dependency-check-build-task@6 + inputs: + projectName: 'SaiJavaCode' + scanPath: '/home/vsts/work/1/s/webapp/target' + format: 'HTML' + +- task: SnykSecurityScan@1 + inputs: + serviceConnectionEndpoint: 'snyk' + testType: 'app' + monitorWhen: 'always' + failOnIssues: false + +- task: SonarCloudPrepare@1 + inputs: + SonarCloud: 'sonarcloud' + organization: 'prajktamhapsekar829' + scannerMode: 'CLI' + configMode: 'manual' + cliProjectKey: 'prajktamhapsekar829' + cliProjectName: 'SaiJavaCode' + cliSources: '.' + extraProperties: | + # Additional properties that will be passed to the scanner, + # Put one key=value per line, example: + # sonar.exclusions=**/*.bin + sonar.java.binaries=. + +- task: SonarCloudAnalyze@1 +- task: SonarCloudPublish@1 + inputs: + pollingTimeoutSec: '300' + +- task: Maven@4 + inputs: + mavenPomFile: 'pom.xml' + goals: 'clean install' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + javaHomeOption: 'JDKVersion' + mavenVersionOption: 'Default' + mavenAuthenticateFeed: false + effectivePomSkip: false + sonarQubeRunAnalysis: false + +- task: CopyFilesOverSSH@0 + inputs: + sshEndpoint: 'tomcat-devsecops-connection' + sourceFolder: '/home/vsts/work/1/s/webapp/target' + contents: '**/*.war' + targetFolder: '/var/lib/tomcat9/webapps' + readyTimeout: '20000' + +- task: owaspzap@1 + inputs: + threshold: '300' + scantype: 'targetedScan' + url: 'http://43.205.232.54:8080/SaiJavaCode' + provideCustomContext: true + contextPath: '/SaiJavaCode' \ No newline at end of file diff --git a/snyk code b/snyk code new file mode 100644 index 00000000..37cc3c71 --- /dev/null +++ b/snyk code @@ -0,0 +1,23 @@ +pipeline { + agent any + stages { + stage('Test') { + steps { + echo 'Testing...' + snykSecurity( + snykInstallation: 'snyk', + snykTokenId: 'snyk cred' + ) + } + } + stage ('SAST') { + steps { + withSonarQubeEnv('SonarQube') { + sh 'mvn package' + sh 'mvn sonar:sonar' + sh 'cat target/sonar/report-task.txt' + } + } + } + } +} diff --git a/webapp/src/main/webapp/index.jsp b/webapp/src/main/webapp/index.jsp index d74e8b60..79566217 100644 --- a/webapp/src/main/webapp/index.jsp +++ b/webapp/src/main/webapp/index.jsp @@ -1,2 +1,4 @@