Skip to content

Commit

Permalink
Postee | Templates | Align vuls templates to the type of the scan
Browse files Browse the repository at this point in the history
This commit aligns the vuls templates to present the type of the scanned entity instead of hard coded "image" as it used to be

Resolves: SLK-71876
  • Loading branch information
RonTG committed Dec 12, 2023
1 parent 31a3987 commit b29dca5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 31 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ input: |
<details>
<summary>Details</summary>

Key | Description | Possible Values | Example
--- | --- | --- | ---
*aggregate-message-number*|Number of messages to aggregate into one message.| any integer value | 10
*aggregate-message-timeout*|number of seconds, minutes, hours to aggregate|Maximum is 24 hours Xs or Xm or Xh | 1h
*unique-message-props*|Optional. Comma separated list of properties which uniquely identifies an event message. If message with same property values is received more than once, consequitive messages will be ignored. | Array of properties that their value uniquely identifies a message | To avoid duplicate scanning messages you can use the following properties: ```unique-message-props: ["digest","image","registry", "vulnerability_summary.high", "vulnerability_summary.medium", "vulnerability_summary.low"]```
*unique-message-timeout*|Optional. Used along with *unique-message-props*, has no effect if unique props are not specified. Number of seconds/minutes/hours/days before expiring of a message. Expired messages are removed from db. If option is empty message is never deleted | 1d
Key | Description | Possible Values | Example
--- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- | ---
*aggregate-message-number*| Number of messages to aggregate into one message. | any integer value | 10
*aggregate-message-timeout*| number of seconds, minutes, hours to aggregate |Maximum is 24 hours Xs or Xm or Xh | 1h
*unique-message-props*| Optional. Comma separated list of properties which uniquely identifies an event message. If message with same property values is received more than once, consecutive messages will be ignored. | Array of properties that their value uniquely identifies a message | To avoid duplicate scanning messages you can use the following properties: ```unique-message-props: ["digest","image","registry", "vulnerability_summary.high", "vulnerability_summary.medium", "vulnerability_summary.low"]```
*unique-message-timeout*| Optional. Used along with *unique-message-props*, has no effect if unique props are not specified. Number of seconds/minutes/hours/days before expiring of a message. Expired messages are removed from db. If option is empty message is never deleted | 1d
</details>

### Templates
Expand Down
8 changes: 4 additions & 4 deletions msgservice/testdata/all-in-one-image.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@
},
{
"name": "CVE-2019-1551",
"description": "There is an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli. No EC algorithms are affected. Analysis suggests that attacks against 2-prime RSA1024, 3-prime RSA1536, and DSA1024 as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH512 are considered just feasible. However, for an attack the target would have to re-use the DH512 private key, which is not recommended anyway. Also applications directly using the low level API BN_mod_exp may be affected if they use BN_FLG_CONSTTIME. Fixed in OpenSSL 1.1.1e (Affected 1.1.1-1.1.1d). Fixed in OpenSSL 1.0.2u (Affected 1.0.2-1.0.2t).",
"description": "There is an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli. No EC algorithms are affected. Analysis suggests that attacks against 2-prime RSA1024, 3-prime RSA1536, and DSA1024 as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH512 are considered just feasible. However, for an attack the target would have to reuse the DH512 private key, which is not recommended anyway. Also applications directly using the low level API BN_mod_exp may be affected if they use BN_FLG_CONSTTIME. Fixed in OpenSSL 1.1.1e (Affected 1.1.1-1.1.1d). Fixed in OpenSSL 1.0.2u (Affected 1.0.2-1.0.2t).",
"nvd_score": 5,
"nvd_score_version": "CVSS v2",
"nvd_vectors": "AV:N/AC:L/Au:N/C:P/I:N/A:N",
Expand Down Expand Up @@ -644,7 +644,7 @@
},
{
"name": "CVE-2020-1968",
"description": "The Raccoon attack exploits a flaw in the TLS specification which can lead to an attacker being able to compute the pre-master secret in connections which have used a Diffie-Hellman (DH) based ciphersuite. In such a case this would result in the attacker being able to eavesdrop on all encrypted communications sent over that TLS connection. The attack can only be exploited if an implementation re-uses a DH secret across multiple TLS connections. Note that this issue only impacts DH ciphersuites and not ECDH ciphersuites. This issue affects OpenSSL 1.0.2 which is out of support and no longer receiving public updates. OpenSSL 1.1.1 is not vulnerable to this issue. Fixed in OpenSSL 1.0.2w (Affected 1.0.2-1.0.2v).",
"description": "The Raccoon attack exploits a flaw in the TLS specification which can lead to an attacker being able to compute the pre-master secret in connections which have used a Diffie-Hellman (DH) based ciphersuite. In such a case this would result in the attacker being able to eavesdrop on all encrypted communications sent over that TLS connection. The attack can only be exploited if an implementation reuses a DH secret across multiple TLS connections. Note that this issue only impacts DH ciphersuites and not ECDH ciphersuites. This issue affects OpenSSL 1.0.2 which is out of support and no longer receiving public updates. OpenSSL 1.1.1 is not vulnerable to this issue. Fixed in OpenSSL 1.0.2w (Affected 1.0.2-1.0.2v).",
"nvd_score": 4.3,
"nvd_score_version": "CVSS v2",
"nvd_vectors": "AV:N/AC:M/Au:N/C:P/I:N/A:N",
Expand Down Expand Up @@ -792,7 +792,7 @@
},
{
"name": "CVE-2019-1551",
"description": "There is an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli. No EC algorithms are affected. Analysis suggests that attacks against 2-prime RSA1024, 3-prime RSA1536, and DSA1024 as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH512 are considered just feasible. However, for an attack the target would have to re-use the DH512 private key, which is not recommended anyway. Also applications directly using the low level API BN_mod_exp may be affected if they use BN_FLG_CONSTTIME. Fixed in OpenSSL 1.1.1e (Affected 1.1.1-1.1.1d). Fixed in OpenSSL 1.0.2u (Affected 1.0.2-1.0.2t).",
"description": "There is an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli. No EC algorithms are affected. Analysis suggests that attacks against 2-prime RSA1024, 3-prime RSA1536, and DSA1024 as a result of this defect would be very difficult to perform and are not believed likely. Attacks against DH512 are considered just feasible. However, for an attack the target would have to reuse the DH512 private key, which is not recommended anyway. Also applications directly using the low level API BN_mod_exp may be affected if they use BN_FLG_CONSTTIME. Fixed in OpenSSL 1.1.1e (Affected 1.1.1-1.1.1d). Fixed in OpenSSL 1.0.2u (Affected 1.0.2-1.0.2t).",
"nvd_score": 5,
"nvd_score_version": "CVSS v2",
"nvd_vectors": "AV:N/AC:L/Au:N/C:P/I:N/A:N",
Expand Down Expand Up @@ -837,7 +837,7 @@
},
{
"name": "CVE-2020-1968",
"description": "The Raccoon attack exploits a flaw in the TLS specification which can lead to an attacker being able to compute the pre-master secret in connections which have used a Diffie-Hellman (DH) based ciphersuite. In such a case this would result in the attacker being able to eavesdrop on all encrypted communications sent over that TLS connection. The attack can only be exploited if an implementation re-uses a DH secret across multiple TLS connections. Note that this issue only impacts DH ciphersuites and not ECDH ciphersuites. This issue affects OpenSSL 1.0.2 which is out of support and no longer receiving public updates. OpenSSL 1.1.1 is not vulnerable to this issue. Fixed in OpenSSL 1.0.2w (Affected 1.0.2-1.0.2v).",
"description": "The Raccoon attack exploits a flaw in the TLS specification which can lead to an attacker being able to compute the pre-master secret in connections which have used a Diffie-Hellman (DH) based ciphersuite. In such a case this would result in the attacker being able to eavesdrop on all encrypted communications sent over that TLS connection. The attack can only be exploited if an implementation reuses a DH secret across multiple TLS connections. Note that this issue only impacts DH ciphersuites and not ECDH ciphersuites. This issue affects OpenSSL 1.0.2 which is out of support and no longer receiving public updates. OpenSSL 1.1.1 is not vulnerable to this issue. Fixed in OpenSSL 1.0.2w (Affected 1.0.2-1.0.2v).",
"nvd_score": 4.3,
"nvd_score_version": "CVSS v2",
"nvd_vectors": "AV:N/AC:M/Au:N/C:P/I:N/A:N",
Expand Down
15 changes: 11 additions & 4 deletions rego-templates/vuls-html.rego
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import data.postee.with_default
################################################ Templates ################################################
#main template to render message
tpl:=`
<p>Image name: %s</p>
<p>%s name: %s</p>
<p>Registry: %s</p>
<p>%s</p>
<p>%s</p>
Expand Down Expand Up @@ -164,17 +164,24 @@ vln_list(severity) = vlnrb {
postee := with_default(input, "postee", {})
aqua_server := with_default(postee, "AquaServer", "")

title = sprintf("%s vulnerability scan report", [input.image])
report_type := "Function" if{
input.entity_type == 1
} else = "VM" if{
input.entity_type == 2
} else = "Image"

title = sprintf(`Aqua security | %s | %s | Scan report`, [report_type, input.image])

aggregation_pkg := "postee.vuls.html.aggregation"
result = msg {

msg := sprintf(tpl, [
report_type,
input.image,
input.registry,
by_flag(
"Image is non-compliant",
"Image is compliant",
sprintf("%s is non-compliant", [report_type]),
sprintf("%s is compliant", [report_type]),
with_default(input.image_assurance_results, "disallowed", false)
),
by_flag(
Expand Down
14 changes: 10 additions & 4 deletions rego-templates/vuls-jira.rego
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ import data.postee.with_default
import data.postee.flat_array #converts [[{...},{...}], [{...},{...}]] to [{...},{...},{...},{...}]
import data.postee.array_concat

title = sprintf("%s vulnerability scan report", [input.image])
report_type := "Function" if{
input.entity_type == 1
} else = "VM" if{
input.entity_type == 2
} else = "Image"

title = sprintf(`Aqua security | %s | %s | Scan report`, [report_type, input.image])

tpl:=`
*Image name:* %s
*%s name:* %s
*Registry:* %s
%s
%s
Expand Down Expand Up @@ -42,11 +47,12 @@ assurance_controls(inp) = l {

result = msg {
msg := sprintf(tpl, [
report_type,
input.image,
input.registry,
by_flag(
"Image is _*non-compliant*_",
"Image is _*compliant*_",
sprintf("%s is _*non-compliant*_", [report_type]),
sprintf("%s is _*compliant*_", [report_type]),
with_default(input.image_assurance_results, "disallowed", false)
),
by_flag(
Expand Down
18 changes: 9 additions & 9 deletions rego-templates/vuls-servicenow.rego
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ postee := with_default(input, "postee", {})
aqua_server := with_default(postee, "AquaServer", "")
server_url := trim_suffix(aqua_server, "images/")

report_type := "function" if{
report_type := "Function" if{
input.entity_type == 1
} else = "vm" if{
} else = "VM" if{
input.entity_type == 2
} else = "image"
} else = "Image"

title = sprintf(`Aqua security | %s | %s | Scan report`, [report_type, input.image])

Expand All @@ -207,15 +207,15 @@ title = sprintf(`Aqua security | %s | %s | Scan report`, [report_type, input.ima
## vm: <server_url>/#/infrastructure/<image>/node
## image: <server_url>/#/image/<registry>/<image>
href := sprintf("%s%s/%s/%s", [server_url, "functions", urlquery.encode(input.registry), urlquery.encode(input.image)]) if{
report_type == "function"
report_type == "Function"
} else = sprintf("%s%s/%s/%s", [server_url, "infrastructure", urlquery.encode(input.image), "node"]){
report_type == "vm"
report_type == "VM"
} else = sprintf("%s%s/%s/%s", [server_url, "image", urlquery.encode(input.registry), urlquery.encode(input.image)])

text := sprintf("%s%s/%s/%s", [server_url, "functions", input.registry, input.image]) if{
report_type == "function"
report_type == "Function"
} else = sprintf("%s%s/%s/%s", [server_url, "infrastructure", input.image, "node"]) {
report_type == "vm"
report_type == "VM"
} else = sprintf("%s%s/%s/%s", [server_url, report_type, input.registry, input.image])

url := by_flag("", href, server_url == "")
Expand Down Expand Up @@ -269,9 +269,9 @@ result = msg {
result_date = input.scan_started.seconds

result_category = "Serverless functions Scanning" if {
report_type == "function"
report_type == "Function"
}else = "Security - VM Scan results" if {
report_type == "vm"
report_type == "VM"
}else = "Security Image Scan results"

result_subcategory = "Security incident"
Expand Down
14 changes: 10 additions & 4 deletions rego-templates/vuls-slack.rego
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ got_vulns(vulnsAll) = [] { #do not render section if provided collection is empt
}

###########################################################################################################
title = sprintf("%s vulnerability scan report", [input.image]) # title is string
report_type := "Function" if{
input.entity_type == 1
} else = "VM" if{
input.entity_type == 2
} else = "Image"

title = sprintf(`Aqua security | %s | %s | Scan report`, [report_type, input.image])

aggregation_pkg := "postee.vuls.slack.aggregation"

Expand All @@ -142,11 +148,11 @@ result = res {
])


headers1 := [{"type":"section","text":{"type":"mrkdwn","text":sprintf("Image name: %s", [input.image])}},
headers1 := [{"type":"section","text":{"type":"mrkdwn","text":sprintf("%s name: %s", [report_type ,input.image])}},
{"type":"section","text":{"type":"mrkdwn","text":sprintf("Registry: %s", [input.registry])}},
{"type":"section","text":{"type":"mrkdwn","text": by_flag(
"Image is non-compliant",
"Image is compliant",
sprintf("%s is non-compliant", [report_type]),
sprintf("%s is compliant", [report_type]),
with_default(input.image_assurance_results, "disallowed", false)
)}},
{"type":"section","text":{"type":"mrkdwn","text": by_flag(
Expand Down

0 comments on commit b29dca5

Please sign in to comment.