From 17c9345e813330cbb674f1d5400a60deb30a95ff Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Tue, 17 Sep 2024 06:52:11 +0000
Subject: [PATCH] Update rule metadata (#1537)
Co-authored-by: rudy-regazzoni-sonarsource In Dockerfiles, a common use case is to download remote resources to use during the build. This is often done using third-party tools inside the
+ In Dockerfiles, a common use case is downloading remote resources to use during the build. This is often done using third-party tools inside the
image, like Sensitive Code Example
S3Bucket:
Type: 'AWS::S3::Bucket' # Sensitive
Properties:
- BucketName: "mynoncompliantbucket"
+ BucketName: "bucketname"
S3BucketPolicy:
Type: 'AWS::S3::BucketPolicy'
@@ -43,7 +43,9 @@ Sensitive Code Example
AWS: # Sensitive: only one principal is forced to use https
- 'arn:aws:iam::123456789123:root'
Action: "*"
- Resource: arn:aws:s3:::mynoncompliantbuckets6249/*
+ Resource:
+ - arn:aws:s3:::bucketname
+ - arn:aws:s3:::bucketname/*
Condition:
Bool:
"aws:SecureTransport": false
@@ -56,12 +58,12 @@ Compliant Solution
S3Bucket:
Type: 'AWS::S3::Bucket' # Compliant
Properties:
- BucketName: "mycompliantbucket"
+ BucketName: "bucketname"
S3BucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
- Bucket: "mycompliantbucket"
+ Bucket: !Ref S3Bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
@@ -69,7 +71,9 @@ Compliant Solution
Principal:
AWS: "*" # all principals should use https
Action: "*" # for any actions
- Resource: arn:aws:s3:::mycompliantbucket/* # for any resources
+ Resource: # for the bucket and all its objects
+ - arn:aws:s3:::bucketname
+ - arn:aws:s3:::bucketname/*
Condition:
Bool:
"aws:SecureTransport": false
diff --git a/iac-extensions/docker/sonarpedia.json b/iac-extensions/docker/sonarpedia.json
index ab2169aa6e..40a1322674 100644
--- a/iac-extensions/docker/sonarpedia.json
+++ b/iac-extensions/docker/sonarpedia.json
@@ -3,7 +3,7 @@
"languages": [
"DOCKER"
],
- "latest-update": "2024-09-02T14:46:56.877054Z",
+ "latest-update": "2024-09-17T06:40:22.621532Z",
"options": {
"no-language-in-filenames": true,
"preserve-filenames": true
diff --git a/iac-extensions/docker/src/main/resources/org/sonar/l10n/docker/rules/docker/S7026.html b/iac-extensions/docker/src/main/resources/org/sonar/l10n/docker/rules/docker/S7026.html
index 77ef476386..45adbb92c3 100644
--- a/iac-extensions/docker/src/main/resources/org/sonar/l10n/docker/rules/docker/S7026.html
+++ b/iac-extensions/docker/src/main/resources/org/sonar/l10n/docker/rules/docker/S7026.html
@@ -1,4 +1,4 @@
-wget
or curl
. However, this practice can lead to inefficient use of Docker’s build cache and unnecessary
complexity. The ADD
instruction is a built-in feature of Docker that is specifically designed for this purpose, making it a more
efficient and safer choice.Why is this an issue?
lead to several issues, particularly related to the inefficient use of Docker’s build cache.
Docker’s build cache is a powerful feature that can significantly speed up the build process by reusing intermediate layers from previous builds if
no changes were detected. When you use wget
, curl
, or similar commands, these commands are run during the build process, and
-Docker has no way of knowing if the remote content has changed without executing the commands. This makes it impossible to effectively cache the
-results of these commands.
Moreover, the installation of third-party tools inside the image can introduce unnecessary complexity, dependency on external tools and increase -the size of the final image.
+Docker has no way of knowing if the remote content has changed without executing the commands. This makes it impossible to cache the results of these +commands efficiently. +Moreover, installing third-party tools inside the image can introduce unnecessary complexity, dependency on external tools and increase the size of +the final image.
+In some cases, the ADD
instruction is not able to replace the wget
or curl
command, especially if specific
+HTTP parameters are required: method, headers, body, etc.
+FROM ubuntu:20.04 +RUN wget --header="Authorization: Bearer your_token" --method=POST https://example.com/resource +
-FROM ununtu:20.04 +FROM ubuntu:20.04 RUN wget https://example.com/resource -O /path/to/resource
-FROM ununtu:20.04 +FROM ubuntu:20.04 RUN curl -o /path/to/resource https://example.com/resource && echo "123456abcdef /path/to/resource" | sha256sum --check
-FROM ununtu:20.04 +FROM ubuntu:20.04 ADD https://example.com/resource /path/to/resource
-FROM ununtu:20.04 +FROM ubuntu:20.04 ADD --checksum=sha256:123456abcdef https://example.com/resource /path/to/resource
Enable certificate-based authentication.
For App Service:
+For Linux and Windows Web Apps:
-resource "azurerm_app_service" "example" { +resource "azurerm_linux_web_app" "example" { client_cert_enabled = false # Sensitive } +resource "azurerm_linux_web_app" "example2" { + client_certificate_enabled = true + client_certificate_mode = "Optional" # Sensitive +}
For Logic App Standards and Function Apps:
@@ -43,21 +47,18 @@For Linux and Windows Web Apps:
+For App Service:
-resource "azurerm_linux_web_app" "example" { +resource "azurerm_app_service" "example" { client_cert_enabled = false # Sensitive } -resource "azurerm_linux_web_app" "exemple2" { - client_cert_enabled = true - client_cert_mode = "Optional" # Sensitive -}
For App Service:
+For Linux and Windows Web Apps:
-resource "azurerm_app_service" "example" { - client_cert_enabled = true +resource "azurerm_linux_web_app" "example" { + client_certificate_enabled = true + client_certificate_mode = "Required" }
For Logic App Standards and Compliant Solution
client_certificate_mode = "Required"
}
- For Linux and Windows Web Apps: For App Service:
-resource "azurerm_linux_web_app" "exemple" {
+resource "azurerm_app_service" "example" {
client_cert_enabled = true
- client_cert_mode = "Required"
}
See