Skip to content

Commit 6d45712

Browse files
hongweiliu17kdudka
authored andcommitted
feat(STONEINTG-1098): setting default KFP_GIT_URL for snyk check
* setting default KFP_GIT_URL to https://gitlab.cee.redhat.com/osh/known-false-positives.git for task running in internal Konflux instance * setting default KFP_GIT_URL to empty string for task running in external Konflux instance Signed-off-by: Kamil Dudka <[email protected]> Signed-off-by: Hongwei Liu <[email protected]>
1 parent 07c9092 commit 6d45712

File tree

8 files changed

+56
-11
lines changed

8 files changed

+56
-11
lines changed

pipelines/docker-build-multi-platform-oci-ta/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ This pipeline is pushed as a Tekton bundle to [quay.io](https://quay.io/reposito
244244
|CACHI2_ARTIFACT| The Trusted Artifact URI pointing to the artifact with the prefetched dependencies.| | '$(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)'|
245245
|IGNORE_FILE_PATHS| Directories or files to be excluded from Snyk scan (Comma-separated). Useful to split the directories of a git repo across multiple components.| | |
246246
|IMP_FINDINGS_ONLY| Report only important findings. Default is true. To report all findings, specify "false"| true| |
247-
|KFP_GIT_URL| URL from repository to download known false positives files| | |
247+
|KFP_GIT_URL| Known False Positives (KFP) git URL (optionally taking a revision delimited by \#). Defaults to "SITE_DEFAULT", which means the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux instance and empty string for external Konflux instance. If set to an empty string, the KFP filtering is disabled.| SITE_DEFAULT| |
248248
|PROJECT_NAME| Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.| | |
249249
|RECORD_EXCLUDED| Write excluded records in file. Useful for auditing (defaults to false).| false| |
250250
|SNYK_SECRET| Name of secret which contains Snyk token.| snyk-secret| |

pipelines/docker-build-oci-ta/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ This pipeline is pushed as a Tekton bundle to [quay.io](https://quay.io/reposito
241241
|CACHI2_ARTIFACT| The Trusted Artifact URI pointing to the artifact with the prefetched dependencies.| | '$(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)'|
242242
|IGNORE_FILE_PATHS| Directories or files to be excluded from Snyk scan (Comma-separated). Useful to split the directories of a git repo across multiple components.| | |
243243
|IMP_FINDINGS_ONLY| Report only important findings. Default is true. To report all findings, specify "false"| true| |
244-
|KFP_GIT_URL| URL from repository to download known false positives files| | |
244+
|KFP_GIT_URL| Known False Positives (KFP) git URL (optionally taking a revision delimited by \#). Defaults to "SITE_DEFAULT", which means the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux instance and empty string for external Konflux instance. If set to an empty string, the KFP filtering is disabled.| SITE_DEFAULT| |
245245
|PROJECT_NAME| Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.| | |
246246
|RECORD_EXCLUDED| Write excluded records in file. Useful for auditing (defaults to false).| false| |
247247
|SNYK_SECRET| Name of secret which contains Snyk token.| snyk-secret| |

pipelines/docker-build/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ This pipeline is pushed as a Tekton bundle to [quay.io](https://quay.io/reposito
218218
|ARGS| Append arguments.| | |
219219
|IGNORE_FILE_PATHS| Directories or files to be excluded from Snyk scan (Comma-separated). Useful to split the directories of a git repo across multiple components.| | |
220220
|IMP_FINDINGS_ONLY| Report only important findings. Default is true. To report all findings, specify "false"| true| |
221-
|KFP_GIT_URL| URL from repository to download known false positives files| | |
221+
|KFP_GIT_URL| Known False Positives (KFP) git URL (optionally taking a revision delimited by \#). Defaults to "SITE_DEFAULT", which means the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux instance and empty string for external Konflux instance. If set to an empty string, the KFP filtering is disabled.| SITE_DEFAULT| |
222222
|PROJECT_NAME| Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.| | |
223223
|RECORD_EXCLUDED| Write excluded records in file. Useful for auditing (defaults to false).| false| |
224224
|SNYK_SECRET| Name of secret which contains Snyk token.| snyk-secret| |

pipelines/maven-zip-build-oci-ta/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ This pipeline is pushed as a Tekton bundle to [quay.io](https://quay.io/reposito
145145
|CACHI2_ARTIFACT| The Trusted Artifact URI pointing to the artifact with the prefetched dependencies.| | '$(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)'|
146146
|IGNORE_FILE_PATHS| Directories or files to be excluded from Snyk scan (Comma-separated). Useful to split the directories of a git repo across multiple components.| | |
147147
|IMP_FINDINGS_ONLY| Report only important findings. Default is true. To report all findings, specify "false"| true| |
148-
|KFP_GIT_URL| URL from repository to download known false positives files| | |
148+
|KFP_GIT_URL| Known False Positives (KFP) git URL (optionally taking a revision delimited by \#). Defaults to "SITE_DEFAULT", which means the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux instance and empty string for external Konflux instance. If set to an empty string, the KFP filtering is disabled.| SITE_DEFAULT| |
149149
|PROJECT_NAME| Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.| | |
150150
|RECORD_EXCLUDED| Write excluded records in file. Useful for auditing (defaults to false).| false| |
151151
|SNYK_SECRET| Name of secret which contains Snyk token.| snyk-secret| |

pipelines/maven-zip-build/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ This pipeline is pushed as a Tekton bundle to [quay.io](https://quay.io/reposito
124124
|ARGS| Append arguments.| | |
125125
|IGNORE_FILE_PATHS| Directories or files to be excluded from Snyk scan (Comma-separated). Useful to split the directories of a git repo across multiple components.| | |
126126
|IMP_FINDINGS_ONLY| Report only important findings. Default is true. To report all findings, specify "false"| true| |
127-
|KFP_GIT_URL| URL from repository to download known false positives files| | |
127+
|KFP_GIT_URL| Known False Positives (KFP) git URL (optionally taking a revision delimited by \#). Defaults to "SITE_DEFAULT", which means the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux instance and empty string for external Konflux instance. If set to an empty string, the KFP filtering is disabled.| SITE_DEFAULT| |
128128
|PROJECT_NAME| Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.| | |
129129
|RECORD_EXCLUDED| Write excluded records in file. Useful for auditing (defaults to false).| false| |
130130
|SNYK_SECRET| Name of secret which contains Snyk token.| snyk-secret| |

task/sast-snyk-check-oci-ta/0.3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See https://snyk.io/product/snyk-code/ and https://snyk.io/ for more information
1515
|CACHI2_ARTIFACT|The Trusted Artifact URI pointing to the artifact with the prefetched dependencies.|""|false|
1616
|IGNORE_FILE_PATHS|Directories or files to be excluded from Snyk scan (Comma-separated). Useful to split the directories of a git repo across multiple components.|""|false|
1717
|IMP_FINDINGS_ONLY|Report only important findings. Default is true. To report all findings, specify "false"|true|false|
18-
|KFP_GIT_URL|URL from repository to download known false positives files|""|false|
18+
|KFP_GIT_URL|Known False Positives (KFP) git URL (optionally taking a revision delimited by \#). Defaults to "SITE_DEFAULT", which means the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux instance and empty string for external Konflux instance. If set to an empty string, the KFP filtering is disabled.|SITE_DEFAULT|false|
1919
|PROJECT_NAME|Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.|""|false|
2020
|RECORD_EXCLUDED|Write excluded records in file. Useful for auditing (defaults to false).|false|false|
2121
|SNYK_SECRET|Name of secret which contains Snyk token.|snyk-secret|false|

task/sast-snyk-check-oci-ta/0.3/sast-snyk-check-oci-ta.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ spec:
3838
type: string
3939
default: "true"
4040
- name: KFP_GIT_URL
41-
description: URL from repository to download known false positives files
41+
description: Known False Positives (KFP) git URL (optionally taking
42+
a revision delimited by \#). Defaults to "SITE_DEFAULT", which means
43+
the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git"
44+
for internal Konflux instance and empty string for external Konflux
45+
instance. If set to an empty string, the KFP filtering is disabled.
4246
type: string
43-
default: ""
47+
default: SITE_DEFAULT
4448
- name: PROJECT_NAME
4549
description: Name of the scanned project, used to find path exclusions.
4650
By default, the Konflux component name will be used.
@@ -128,6 +132,10 @@ spec:
128132
valueFrom:
129133
fieldRef:
130134
fieldPath: metadata.labels['appstudio.openshift.io/component']
135+
- name: BUILD_PLR_LOG_URL
136+
valueFrom:
137+
fieldRef:
138+
fieldPath: metadata.annotations['pipelinesascode.tekton.dev/log-url']
131139
script: |
132140
#!/usr/bin/env bash
133141
@@ -196,6 +204,21 @@ spec:
196204
echo "Results:"
197205
(set -x && csgrep --mode=evtstat sast_snyk_check_out_all_findings.json)
198206
207+
# Set KFP_GIT_URL to https://gitlab.cee.redhat.com/osh/known-false-positives.git for internal Konflux instance
208+
# p01 will be decommissionned due to lack of IBM support
209+
if [[ "${KFP_GIT_URL}" == "SITE_DEFAULT" ]]; then
210+
case "${BUILD_PLR_LOG_URL}" in
211+
*konflux.apps.stone-prod-p02.hjvn.p1.openshiftapps.com* | *konflux.apps.stone-prod-p01.wcfb.p1.openshiftapps.com*)
212+
echo "the task is running within Red Hat network, set KFP_GIT_URL to https://gitlab.cee.redhat.com/osh/known-false-positives.git"
213+
KFP_GIT_URL="https://gitlab.cee.redhat.com/osh/known-false-positives.git"
214+
;;
215+
*)
216+
echo "the task is not running within Red Hat network, set KFP_GIT_URL to empty string"
217+
KFP_GIT_URL=
218+
;;
219+
esac
220+
fi
221+
199222
# We check if the KFP_GIT_URL variable is set to apply the filters or not
200223
if [[ -z "${KFP_GIT_URL}" ]]; then
201224
echo "KFP_GIT_URL variable not defined. False positives won't be filtered"

task/sast-snyk-check/0.3/sast-snyk-check.yaml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ spec:
4646
default: "true"
4747
- name: KFP_GIT_URL
4848
type: string
49-
description: URL from repository to download known false positives files
50-
# FIXME: Red Hat internal projects will default to https://gitlab.cee.redhat.com/osh/known-false-positives.git when KONFLUX-4530 is resolved
51-
default: ""
49+
description: Known False Positives (KFP) git URL (optionally taking
50+
a revision delimited by \#). Defaults to "SITE_DEFAULT", which means
51+
the default value "https://gitlab.cee.redhat.com/osh/known-false-positives.git" for internal Konflux
52+
instance and empty string for external Konflux instance.
53+
If set to an empty string, the KFP filtering is disabled.
54+
default: "SITE_DEFAULT"
5255
- name: PROJECT_NAME
5356
type: string
5457
description: Name of the scanned project, used to find path exclusions. By default, the Konflux component name will be used.
@@ -105,6 +108,10 @@ spec:
105108
valueFrom:
106109
fieldRef:
107110
fieldPath: metadata.labels['appstudio.openshift.io/component']
111+
- name: BUILD_PLR_LOG_URL
112+
valueFrom:
113+
fieldRef:
114+
fieldPath: metadata.annotations['pipelinesascode.tekton.dev/log-url']
108115
script: |
109116
#!/usr/bin/env bash
110117
@@ -173,6 +180,21 @@ spec:
173180
echo "Results:"
174181
(set -x && csgrep --mode=evtstat sast_snyk_check_out_all_findings.json)
175182
183+
# Set KFP_GIT_URL to https://gitlab.cee.redhat.com/osh/known-false-positives.git for internal Konflux instance
184+
# p01 will be decommissionned due to lack of IBM support
185+
if [[ "${KFP_GIT_URL}" == "SITE_DEFAULT" ]]; then
186+
case "${BUILD_PLR_LOG_URL}" in
187+
*konflux.apps.stone-prod-p02.hjvn.p1.openshiftapps.com* | *konflux.apps.stone-prod-p01.wcfb.p1.openshiftapps.com*)
188+
echo "the task is running within Red Hat network, set KFP_GIT_URL to https://gitlab.cee.redhat.com/osh/known-false-positives.git"
189+
KFP_GIT_URL="https://gitlab.cee.redhat.com/osh/known-false-positives.git"
190+
;;
191+
*)
192+
echo "the task is not running within Red Hat network, set KFP_GIT_URL to empty string"
193+
KFP_GIT_URL=
194+
;;
195+
esac
196+
fi
197+
176198
# We check if the KFP_GIT_URL variable is set to apply the filters or not
177199
if [[ -z "${KFP_GIT_URL}" ]]; then
178200
echo "KFP_GIT_URL variable not defined. False positives won't be filtered"

0 commit comments

Comments
 (0)