Skip to content

Commit 17c9345

Browse files
Update rule metadata (#1537)
Co-authored-by: rudy-regazzoni-sonarsource <rudy-regazzoni-sonarsource>
1 parent 45fdb41 commit 17c9345

File tree

9 files changed

+45
-34
lines changed

9 files changed

+45
-34
lines changed

iac-extensions/arm/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"AZURE_RESOURCE_MANAGER"
55
],
6-
"latest-update": "2024-09-02T14:46:42.140530Z",
6+
"latest-update": "2024-09-17T06:40:06.632039Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

iac-extensions/cloudformation/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"CLOUD_FORMATION"
55
],
6-
"latest-update": "2024-09-02T14:46:49.511642Z",
6+
"latest-update": "2024-09-17T06:40:14.503224Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

iac-extensions/cloudformation/src/main/resources/org/sonar/l10n/cloudformation/rules/cloudformation/S6249.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h2>Sensitive Code Example</h2>
2929
S3Bucket:
3030
Type: 'AWS::S3::Bucket' # Sensitive
3131
Properties:
32-
BucketName: "mynoncompliantbucket"
32+
BucketName: "bucketname"
3333

3434
S3BucketPolicy:
3535
Type: 'AWS::S3::BucketPolicy'
@@ -43,7 +43,9 @@ <h2>Sensitive Code Example</h2>
4343
AWS: # Sensitive: only one principal is forced to use https
4444
- 'arn:aws:iam::123456789123:root'
4545
Action: "*"
46-
Resource: arn:aws:s3:::mynoncompliantbuckets6249/*
46+
Resource:
47+
- arn:aws:s3:::bucketname
48+
- arn:aws:s3:::bucketname/*
4749
Condition:
4850
Bool:
4951
"aws:SecureTransport": false
@@ -56,20 +58,22 @@ <h2>Compliant Solution</h2>
5658
S3Bucket:
5759
Type: 'AWS::S3::Bucket' # Compliant
5860
Properties:
59-
BucketName: "mycompliantbucket"
61+
BucketName: "bucketname"
6062

6163
S3BucketPolicy:
6264
Type: 'AWS::S3::BucketPolicy'
6365
Properties:
64-
Bucket: "mycompliantbucket"
66+
Bucket: !Ref S3Bucket
6567
PolicyDocument:
6668
Version: "2012-10-17"
6769
Statement:
6870
- Effect: Deny
6971
Principal:
7072
AWS: "*" # all principals should use https
7173
Action: "*" # for any actions
72-
Resource: arn:aws:s3:::mycompliantbucket/* # for any resources
74+
Resource: # for the bucket and all its objects
75+
- arn:aws:s3:::bucketname
76+
- arn:aws:s3:::bucketname/*
7377
Condition:
7478
Bool:
7579
"aws:SecureTransport": false

iac-extensions/docker/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"DOCKER"
55
],
6-
"latest-update": "2024-09-02T14:46:56.877054Z",
6+
"latest-update": "2024-09-17T06:40:22.621532Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

iac-extensions/docker/src/main/resources/org/sonar/l10n/docker/rules/docker/S7026.html

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<p>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
1+
<p>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
22
image, like <code>wget</code> or <code>curl</code>. However, this practice can lead to inefficient use of Docker’s build cache and unnecessary
33
complexity. The <code>ADD</code> instruction is a built-in feature of Docker that is specifically designed for this purpose, making it a more
44
efficient and safer choice.</p>
@@ -7,28 +7,35 @@ <h2>Why is this an issue?</h2>
77
lead to several issues, particularly related to the inefficient use of Docker’s build cache.</p>
88
<p>Docker’s build cache is a powerful feature that can significantly speed up the build process by reusing intermediate layers from previous builds if
99
no changes were detected. When you use <code>wget</code>, <code>curl</code>, or similar commands, these commands are run during the build process, and
10-
Docker has no way of knowing if the remote content has changed without executing the commands. This makes it impossible to effectively cache the
11-
results of these commands.</p>
12-
<p>Moreover, the installation of third-party tools inside the image can introduce unnecessary complexity, dependency on external tools and increase
13-
the size of the final image.</p>
10+
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
11+
commands efficiently.</p>
12+
<p>Moreover, installing third-party tools inside the image can introduce unnecessary complexity, dependency on external tools and increase the size of
13+
the final image.</p>
14+
<h3>Exceptions</h3>
15+
<p>In some cases, the <code>ADD</code> instruction is not able to replace the <code>wget</code> or <code>curl</code> command, especially if specific
16+
HTTP parameters are required: method, headers, body, etc.</p>
17+
<pre>
18+
FROM ubuntu:20.04
19+
RUN wget --header="Authorization: Bearer your_token" --method=POST https://example.com/resource
20+
</pre>
1421
<h2>How to fix it</h2>
1522
<h3>Code examples</h3>
1623
<h4>Noncompliant code example</h4>
1724
<pre data-diff-id="1" data-diff-type="noncompliant">
18-
FROM ununtu:20.04
25+
FROM ubuntu:20.04
1926
RUN wget https://example.com/resource -O /path/to/resource
2027
</pre>
2128
<pre data-diff-id="2" data-diff-type="noncompliant">
22-
FROM ununtu:20.04
29+
FROM ubuntu:20.04
2330
RUN curl -o /path/to/resource https://example.com/resource &amp;&amp; echo "123456abcdef /path/to/resource" | sha256sum --check
2431
</pre>
2532
<h4>Compliant solution</h4>
2633
<pre data-diff-id="1" data-diff-type="compliant">
27-
FROM ununtu:20.04
34+
FROM ubuntu:20.04
2835
ADD https://example.com/resource /path/to/resource
2936
</pre>
3037
<pre data-diff-id="2" data-diff-type="compliant">
31-
FROM ununtu:20.04
38+
FROM ubuntu:20.04
3239
ADD --checksum=sha256:123456abcdef https://example.com/resource /path/to/resource
3340
</pre>
3441
<h2>Resources</h2>

iac-extensions/kubernetes/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"KUBERNETES"
55
],
6-
"latest-update": "2024-09-02T14:47:03.763797Z",
6+
"latest-update": "2024-09-17T06:40:30.052792Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

iac-extensions/kubernetes/src/main/resources/org/sonar/l10n/kubernetes/rules/kubernetes/S6430.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ <h2>Compliant Solution</h2>
5151
<h2>See</h2>
5252
<ul>
5353
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/284">CWE-284 - Improper Access Control</a> </li>
54-
<li> <a href="https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt">Linux Kernel Archives, no_new_privs</a> - Official docs </li>
54+
<li> <a href="https://docs.kernel.org/userspace-api/no_new_privs.html">Linux Kernel Archives, no_new_privs</a> - Official docs </li>
5555
</ul>
5656

iac-extensions/terraform/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"TERRAFORM"
55
],
6-
"latest-update": "2024-09-02T14:47:11.602411Z",
6+
"latest-update": "2024-09-17T06:40:38.583237Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

iac-extensions/terraform/src/main/resources/org/sonar/l10n/terraform/rules/terraform/S6382.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ <h2>Ask Yourself Whether</h2>
1717
<h2>Recommended Secure Coding Practices</h2>
1818
<p>Enable certificate-based authentication.</p>
1919
<h2>Sensitive Code Example</h2>
20-
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/">App Service</a>:</p>
20+
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/containers/">Linux and Windows Web Apps</a>:</p>
2121
<pre data-diff-id="1" data-diff-type="noncompliant">
22-
resource "azurerm_app_service" "example" {
22+
resource "azurerm_linux_web_app" "example" {
2323
client_cert_enabled = false # Sensitive
2424
}
25+
resource "azurerm_linux_web_app" "example2" {
26+
client_certificate_enabled = true
27+
client_certificate_mode = "Optional" # Sensitive
28+
}
2529
</pre>
2630
<p>For <a href="https://azure.microsoft.com/en-us/services/logic-apps/">Logic App Standards</a> and <a
2731
href="https://azure.microsoft.com/en-us/services/functions/">Function Apps</a>:</p>
@@ -43,21 +47,18 @@ <h2>Sensitive Code Example</h2>
4347
client_certificate_mode = "Optional" # Sensitive
4448
}
4549
</pre>
46-
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/containers/">Linux and Windows Web Apps</a>:</p>
50+
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/">App Service</a>:</p>
4751
<pre data-diff-id="5" data-diff-type="noncompliant">
48-
resource "azurerm_linux_web_app" "example" {
52+
resource "azurerm_app_service" "example" {
4953
client_cert_enabled = false # Sensitive
5054
}
51-
resource "azurerm_linux_web_app" "exemple2" {
52-
client_cert_enabled = true
53-
client_cert_mode = "Optional" # Sensitive
54-
}
5555
</pre>
5656
<h2>Compliant Solution</h2>
57-
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/">App Service</a>:</p>
57+
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/containers/">Linux and Windows Web Apps</a>:</p>
5858
<pre data-diff-id="1" data-diff-type="compliant">
59-
resource "azurerm_app_service" "example" {
60-
client_cert_enabled = true
59+
resource "azurerm_linux_web_app" "example" {
60+
client_certificate_enabled = true
61+
client_certificate_mode = "Required"
6162
}
6263
</pre>
6364
<p>For <a href="https://azure.microsoft.com/en-us/services/logic-apps/">Logic App Standards</a> and <a
@@ -80,11 +81,10 @@ <h2>Compliant Solution</h2>
8081
client_certificate_mode = "Required"
8182
}
8283
</pre>
83-
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/containers/">Linux and Windows Web Apps</a>:</p>
84+
<p>For <a href="https://azure.microsoft.com/en-us/services/app-service/">App Service</a>:</p>
8485
<pre data-diff-id="5" data-diff-type="compliant">
85-
resource "azurerm_linux_web_app" "exemple" {
86+
resource "azurerm_app_service" "example" {
8687
client_cert_enabled = true
87-
client_cert_mode = "Required"
8888
}
8989
</pre>
9090
<h2>See</h2>

0 commit comments

Comments
 (0)