Giter Club home page Giter Club logo

Comments (5)

marcinguy avatar marcinguy commented on August 12, 2024

hi @dkajla

Make sure it is a Git repo, otherwise it will also error out.

On a mobile now. Try this:

  - job: SAST
    displayName: Static Application Security Test (SAST)
    condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
    pool:
      vmImage: 'ubuntu-latest'
    container: 'scanmycode/scanmycode3-ce:worker-cli'
    steps:
    - script: |
        sudo apt-get update
        sudo apt-get install git-lfs
      displayName: Install git LFS
      
    - checkout: self
      persistCredentials: true

    - script: |
        set -e
        git config --global user.email "[email protected]"
        git config --global user.name "Azure DevOps" 
        git checkout -b $(Build.SourceBranchName)
        sudo CODE_DIR=$(Build.SourcesDirectory) checkmate init
        sudo CODE_DIR=$(Build.SourcesDirectory) checkmate git init
        sudo CODE_DIR=$(Build.SourcesDirectory) checkmate git analyze --branch $(Build.SourceBranchName)
        checkmate issues html
      displayName: Static Application Security Test (SAST)
      env:
        CODE_DIR: '$(Build.SourcesDirectory)'

    - task: PublishBuildArtifacts@1
      displayName: Publish SAST report
      inputs:
        PathtoPublish: $(Build.SourcesDirectory)
        ArtifactName: CodeAnalysisLogs

    - script: |
        git add .checkmate/db.sqlite
        git commit -m '[no ci] update checkmate db'
        git push origin $(Build.SourceBranchName):$(Build.SourceBranch)
      displayName: Commit and Push checkmate db

Notice two new lines:

        sudo CODE_DIR=$(Build.SourcesDirectory) checkmate init
        sudo CODE_DIR=$(Build.SourcesDirectory) checkmate git init

Please let me know how it works.

Also can you scan this repo and send screenshot from Azure DevOps server showing results:

https://github.com/topcodersonline/samplecode

from betterscan.

devendrakajala avatar devendrakajala commented on August 12, 2024

Hi @marcinguy Thanks for the response.

Yes it did fix the issue I was facing. Additionally, I had to add sudo CODE_DIR=$(Build.SourcesDirectory) ahead of checkmate issues html for the job to complete successfully.

I have few more questions :)

  1. Is the final script needed ? which is committing the db file into repo git commit -m '[no ci] update checkmate db, as its triggering pipeline continuously.
  2. Is there a option that the tool can scan PR's and add comments automatically. Apologies for multiple questions, I couldn't find any detailed documentation about these configurations.

from betterscan.

marcinguy avatar marcinguy commented on August 12, 2024

hi @devendrakajala

  1. this step ensures state is preserved (project will not be rescanned each time for checked files)

I think you can do exclusion for ".checkmate" folder with file types exclusion trigger:

https://stackoverflow.com/questions/55731861/exclude-file-types-in-ci-triggers-on-azure-devops-pipelines-builds

https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops

  1. Scanning PR is possible, then you would see findings for PR only. You should check what Azure DevOps server can do.

Maybe @carlin-q-scott knows more. He contributed Azure DevOps server setup.

P.S @devendrakajala Screenshot of sample repo from Azure DevOps server would be helpful. Maybe you can paste it here or send me on my email. I will add it to documentation.

from betterscan.

carlin-q-scott avatar carlin-q-scott commented on August 12, 2024

@devendrakajala The commit should not be triggering CI, as the [no ci] commit message is supposed to prevent that. I've found that they broke support for that particular message recently, but [ci skip] seems to work for me with a BitBucket repo.

Due to another bug I found with Azure DevOps, I ended up persisting my .checkmate folder to blob storage and leaving it out of the git repo entirely. My issue was that the git credentials aren't persisted properly within a container job when using BitBucket as the git repo.

from betterscan.

devendrakajala avatar devendrakajala commented on August 12, 2024

Thanks for your comments guys @marcinguy @carlin-q-scott using [ci skip] helped.

from betterscan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.