Skip to content

Commit

Permalink
Merge pull request #34 from szEvEz/main
Browse files Browse the repository at this point in the history
Use re-import endpoint to upload scans if there is a test existing
  • Loading branch information
rndmh3ro authored Nov 27, 2023
2 parents a52770d + 1d61b5a commit e38d38d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ docker run -it -v /path/to/your/.kube/config:/root/.kube/config -e DEFECT_DOJO_A
| `defectDojoPushToJira` | `"false"` | Specifies whether findings should be pushed to Jira in DefectDojo. |
| `defectDojoTestTitle` | `Kubernetes` | The title of the test in DefectDojo. |
| `defectDojoVerified` | `"false"` | Specifies whether findings should be marked as verified in DefectDojo. |
| `defectDojoDoNotReactivate` | `"true"` | If true the importing/reimporting will ignore uploaded active findings and not reactivate previously closed findings, while still creating new findings if there are new ones |

## A note on eval

Expand Down
3 changes: 3 additions & 0 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ spec:
- name: DEFECT_DOJO_EVAL_PRODUCT_NAME
value: {{ quote .Values.operator.trivyDojoReportOperator.env.defectDojoEvalProductName
}}
- name: DEFECT_DOJO_DO_NOT_REACTIVATE
value: {{ quote .Values.operator.trivyDojoReportOperator.env.defectDojoDoNotReactivate
}}
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.operator.trivyDojoReportOperator.image.repository }}:{{ .Values.operator.trivyDojoReportOperator.image.tag
Expand Down
3 changes: 2 additions & 1 deletion charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ operator:
defectDojoCloseOldFindings: "false"
defectDojoCloseOldFindingsProductScope: "false"
defectDojoDeduplicationOnEngagement: "true"
defectDojoDoNotReactivate: "true"
defectDojoEngagementName: engagement
defectDojoEvalEngagementName: "false"
defectDojoEvalProductName: "false"
Expand All @@ -32,5 +33,5 @@ operator:
defectDojoVerified: "false"
image:
repository: ghcr.io/telekom-mms/docker-trivy-dojo-operator
tag: trivy-dojo-report-operator-0.3.5@sha256:e0def24a52696acfa61ca43b508da654c5bab56b116de5764d9de55407b529eb
tag: trivy-dojo-report-operator-0.3.5
type: ClusterIP
4 changes: 3 additions & 1 deletion deploy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
serviceAccountName: trivy-dojo-report-account
containers:
- name: trivy-dojo-report-operator
image: ghcr.io/telekom-mms/docker-trivy-dojo-operator:0.3.3
image: ghcr.io/telekom-mms/docker-trivy-dojo-operator:trivy-dojo-report-operator-0.3.5
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -71,3 +71,5 @@ spec:
value: "product"
- name: DEFECT_DOJO_EVAL_PRODUCT_NAME
value: "false"
- name: DEFECT_DOJO_DO_NOT_REACTIVATE
value: "true"
1 change: 1 addition & 0 deletions docs/LOCAL-DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ environment for this operator.
export LABEL="trivy-operator.resource.name"; export LABEL_VALUE="your_label_value";
export DEFECT_DOJO_ENGAGEMENT_NAME="test"
export DEFECT_DOJO_AUTO_CREATE_CONTEXT=true
export DEFECT_DOJO_ACTIVE=true
```

- Install the Python dependencies
Expand Down
3 changes: 2 additions & 1 deletion src/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ def send_to_dojo(body, meta, logger, **_):
"product_name": _DEFECT_DOJO_PRODUCT_NAME,
"product_type_name": _DEFECT_DOJO_PRODUCT_TYPE_NAME,
"test_title": _DEFECT_DOJO_TEST_TITLE,
"do_not_reactivate": settings.DEFECT_DOJO_DO_NOT_REACTIVATE,
}

logger.debug(data)

try:
response: requests.Response = requests.post(
settings.DEFECT_DOJO_URL + "/api/v2/import-scan/",
settings.DEFECT_DOJO_URL + "/api/v2/reimport-scan/",
headers=headers,
data=data,
files=report_file,
Expand Down
2 changes: 2 additions & 0 deletions src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@
"DEFECT_DOJO_PRODUCT_NAME", "Research and Development"
)
DEFECT_DOJO_EVAL_PRODUCT_NAME: bool = get_env_var_bool("DEFECT_DOJO_EVAL_PRODUCT_NAME")

DEFECT_DOJO_DO_NOT_REACTIVATE: bool = get_env_var_bool("DEFECT_DOJO_DO_NOT_REACTIVATE")

0 comments on commit e38d38d

Please sign in to comment.