Skip to content

Commit

Permalink
Merge branch 'master' into alexlink/pr/utilsStash
Browse files Browse the repository at this point in the history
  • Loading branch information
alxsap authored Jul 7, 2023
2 parents 535c9ca + 610e212 commit 42d9b03
Show file tree
Hide file tree
Showing 73 changed files with 2,175 additions and 308 deletions.
10 changes: 10 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"ignorePaths": [
"integration/testdata/**",
"test/resources/**"
]
}
3 changes: 2 additions & 1 deletion .github/workflows/consumer-tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ jobs:
with:
repository: ${{ steps.repository.outputs.repository }}
ref: ${{ steps.branch_name.outputs.branch_name }}
- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu
- name: Install Groovy
run: |
sudo apt-get update
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/consumer-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
steps:
- uses: styfle/[email protected]
- uses: actions/checkout@v3
- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu
- name: Install Groovy
run: |
sudo apt-get update
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,30 @@ jobs:
steps:
- uses: styfle/[email protected]

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: '1.8'
java-version: 8
distribution: zulu

- uses: actions/setup-go@v1
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'

- name: Install Groovy
run: sudo apt-get update && sudo apt-get install groovy -y

- name: Cache Maven Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Cache Go Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ needs.start.outputs.sha }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.start.outputs.go_version }}
- name: Build
Expand All @@ -98,7 +98,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ needs.start.outputs.sha }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.start.outputs.go_version }}
- name: Build
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ needs.start.outputs.sha }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.start.outputs.go_version }}
- name: Download Piper binary
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ needs.start.outputs.sha }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.start.outputs.go_version }}
- name: Build
Expand All @@ -70,7 +70,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ needs.start.outputs.sha }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.start.outputs.go_version }}
- name: Build
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ needs.start.outputs.sha }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.start.outputs.go_version }}
- name: Download Piper binary
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: 'Format'
steps:
- uses: styfle/[email protected]
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Markdown Linting
uses: nosborn/[email protected]
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
- uses: actions/checkout@v1
- uses: actions/checkout@v3
# Workaround for https://github.com/SAP/jenkins-library/issues/1723, build only works with jdk8 currently
- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: '8'
java-version: 8
distribution: zulu
- name: Prepare Release
run: |
curl --insecure --silent --location --write-out '%{http_code}' --output ./piper_master https://github.com/SAP/jenkins-library/releases/latest/download/piper_master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
- uses: actions/stale@v4
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Thank you for your contribution! This issue is stale because it has been open 60 days with no activity. In order to keep it open, please remove stale label or add a comment within the next 10 days. If you need a Piper team member to remove the stale label make sure to add `@SAP/jenkins-library-team` to your comment.'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-go-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'
- name: Perform update
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-go-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'
- env:
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/verify-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
- uses: actions/setup-go@v1
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'
- name: Cache Golang Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: unit-test
uses: paambaati/codeclimate-action@v2.6.0
uses: paambaati/codeclimate-action@v4
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
with:
Expand All @@ -37,32 +37,32 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'
- name: Cache Golang Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-format${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-format
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: format
run: go fmt ./...
- name: verify
run: git diff --exit-code
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
- uses: actions/setup-go@v4
with:
go-version: '1.19.x'
# action requires [email protected]
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: staticcheck
Expand All @@ -73,39 +73,39 @@ jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'
- name: Cache Golang Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-generate${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-generate
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: generate
run: go run pkg/generator/step-metadata.go
- name: verify
run: git diff --exit-code
dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
- uses: actions/setup-go@v4
with:
go-version: '1.18.x'
- name: Cache Golang Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-golang-dependencies${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-golang-dependencies
${{ runner.os }}-golang-
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: cleanup dependencies
run: go mod tidy
- name: verify
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/verify-groovy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ jobs:
steps:
- uses: styfle/[email protected]

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: 1.8
java-version: 8
distribution: zulu

- name: Cache Maven Packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: styfle/[email protected]
- uses: actions/checkout@master

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COPY . /build
WORKDIR /build

# execute tests
RUN go test ./... -cover
RUN go test ./... -tags=unit -cover

## ONLY tests so far, building to be added later
# execute build
Expand Down
25 changes: 19 additions & 6 deletions cmd/checkmarxOneExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,17 @@ func (c *checkmarxOneExecuteScanHelper) SetProjectPreset() error {
}

if c.config.Preset == "" {
log.Entry().Infof("Pipeline yaml does not specify a preset, will use project configuration (%v).", currentPreset)
if currentPreset == "" {
return fmt.Errorf("must specify the preset in either the pipeline yaml or in the CheckmarxOne project configuration")
} else {
log.Entry().Infof("Pipeline yaml does not specify a preset, will use project configuration (%v).", currentPreset)
}
c.config.Preset = currentPreset
} else if currentPreset != c.config.Preset {
log.Entry().Infof("Project configured preset (%v) does not match pipeline yaml (%v) - updating project configuration.", currentPreset, c.config.Preset)
c.sys.SetProjectPreset(c.Project.ProjectID, c.config.Preset, true)
} else {
log.Entry().Infof("Project is configured to use preset %v", currentPreset)
log.Entry().Infof("Project is already configured to use pipeline preset %v", currentPreset)
}
return nil
}
Expand Down Expand Up @@ -532,12 +536,17 @@ func (c *checkmarxOneExecuteScanHelper) ParseResults(scan *checkmarxOne.Scan) (m
return detailedResults, fmt.Errorf("Unable to fetch scan metadata for scan %v: %s", scan.ScanID, err)
}

totalResultCount := uint64(0)

scansummary, err := c.sys.GetScanSummary(scan.ScanID)
if err != nil {
return detailedResults, fmt.Errorf("Unable to fetch scan summary for scan %v: %s", scan.ScanID, err)
/* TODO: scansummary throws a 404 for 0-result scans, once the bug is fixed put this code back. */
// return detailedResults, fmt.Errorf("Unable to fetch scan summary for scan %v: %s", scan.ScanID, err)
} else {
totalResultCount = scansummary.TotalCount()
}

results, err := c.sys.GetScanResults(scan.ScanID, scansummary.TotalCount())
results, err := c.sys.GetScanResults(scan.ScanID, totalResultCount)
if err != nil {
return detailedResults, fmt.Errorf("Unable to fetch scan results for scan %v: %s", scan.ScanID, err)
}
Expand Down Expand Up @@ -606,12 +615,15 @@ func (c *checkmarxOneExecuteScanHelper) generateAndDownloadReport(scan *checkmar

if finalStatus.Status == "completed" {
break
} else if finalStatus.Status == "failed" {
return []byte{}, fmt.Errorf("report generation failed")
}
time.Sleep(10 * time.Second)
}
if finalStatus.Status == "completed" {
return c.sys.DownloadReport(finalStatus.ReportURL)
}

return []byte{}, fmt.Errorf("unexpected status %v recieved", finalStatus.Status)
}

Expand Down Expand Up @@ -954,8 +966,9 @@ func (c *checkmarxOneExecuteScanHelper) enforceThresholds(results *map[string]in
}
// if the flag is switched on, calculate the Low findings threshold per query
if cxLowThresholdPerQuery {
lowPerQueryMap := (*results)["LowPerQuery"].(map[string]map[string]int)
if lowPerQueryMap != nil {
if (*results)["LowPerQuery"] != nil {
lowPerQueryMap := (*results)["LowPerQuery"].(map[string]map[string]int)

for lowQuery, resultsLowQuery := range lowPerQueryMap {
lowAuditedPerQuery := resultsLowQuery["Confirmed"] + resultsLowQuery["NotExploitable"]
lowOverallPerQuery := resultsLowQuery["Issues"]
Expand Down
Loading

0 comments on commit 42d9b03

Please sign in to comment.