Skip to content

Commit 1d6133e

Browse files
SONARJAVA-6178 Update rule metadata (#5499)
Co-authored-by: tomasz-tylenda-sonarsource <tomasz-tylenda-sonarsource@users.noreply.github.com>
1 parent 53fc4bb commit 1d6133e

File tree

6 files changed

+31
-28
lines changed

6 files changed

+31
-28
lines changed

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S4684.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<p>With Spring, when a request mapping method is configured to accept bean objects as arguments, the framework will automatically bind HTTP parameters
2-
to those objects' properties. If the targeted beans are also persistent entities, the framework will also store those properties in the storage
3-
backend, usually the application’s database.</p>
1+
<p>Mass assignment occurs when a framework automatically binds user-controlled input to objects that are directly persisted to a database backend. If
2+
the application does not restrict which fields are writable, an attacker can inject additional properties into a request to overwrite sensitive
3+
data—such as authorization levels, ownership, or workflow states. This lack of filtering allows internal server-managed properties to be externally
4+
modified through a single, unfiltered write operation.</p>
45
<h2>Why is this an issue?</h2>
5-
<p>By accepting persistent entities as method arguments, the application allows clients to manipulate the object’s properties directly.</p>
6+
<p>Because the application does not enforce which fields are writable, an attacker can craft a request containing any document property, including
7+
those that are meant to be managed exclusively by the server. Fields controlling authorization, ownership, workflow state, or internal identifiers all
8+
become externally settable through a single unfiltered write operation.</p>
69
<h3>What is the potential impact?</h3>
710
<p>Attackers could forge malicious HTTP requests that will alter unexpected properties of persistent objects. This can lead to unauthorized
811
modifications of the entity’s state. This is known as a <strong>mass assignment</strong> attack.</p>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S4684.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Persistent entities should not be used as arguments of \"@RequestMapping\" methods",
2+
"title": "Database Operations should not be vulnerable to mass assignment",
33
"type": "VULNERABILITY",
44
"code": {
55
"impacts": {

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S8446.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ <h4>Compliant solution</h4>
4141
<h2>Resources</h2>
4242
<h3>Documentation</h3>
4343
<ul>
44-
<li> <a href="https://openjdk.org/jeps/512">JEP 512: Compact Source Files and Instance Main Methods</a> </li>
44+
<li><a href="https://openjdk.org/jeps/512">JEP 512: Compact Source Files and Instance Main Methods</a></li>
4545
</ul>
4646

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S8446.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Only one \"main\" method should be present",
2+
"title": "Only one \"main\" method should be defined in a class",
33
"type": "CODE_SMELL",
44
"status": "ready",
55
"remediation": {

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S8447.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ <h2>Why is this an issue?</h2>
55
<p>Traditionally, the explicit constructor invocation (<code>super(…​)</code> or <code>this(…​)</code>) had to be the first statement in a
66
constructor, forcing subclass field initialization to happen after the superclass was already constructed. If the superclass constructor calls an
77
overridable method, the subclass implementation will see default values (such as <code>null</code>, <code>0</code>, or <code>false</code>) for its
8-
fields instead of the values intended by the caller. This leads to subtle bugs, `NullPointerException`s, or inconsistent object states that are
9-
difficult to debug.</p>
8+
fields instead of the values intended by the caller. This leads to subtle bugs, <code>NullPointerException</code>s, or inconsistent object states that
9+
are difficult to debug.</p>
1010
<h2>How to fix it</h2>
1111
<p>Move the initialization of subclass fields before the <code>super()</code> call. This takes advantage of flexible constructor bodies to ensure that
1212
the subclass state is established before the superclass constructor begins its execution. Alternatively, if the method in the superclass does not need
@@ -16,10 +16,10 @@ <h4>Noncompliant code example</h4>
1616
<pre data-diff-id="1" data-diff-type="noncompliant">
1717
class Super {
1818
Super() {
19-
overriddenMethod();
19+
foo();
2020
}
2121

22-
void overriddenMethod() {
22+
void foo() {
2323
System.out.println("Base logic");
2424
}
2525
}
@@ -29,11 +29,11 @@ <h4>Noncompliant code example</h4>
2929

3030
Sub(int x) {
3131
super();
32-
this.x = x; // Noncompliant: x is uninitialized when overriddenMethod is called by Super()
32+
this.x = x; // Noncompliant: x is uninitialized when foo is called by Super()
3333
}
3434

3535
@Override
36-
void overriddenMethod() {
36+
void foo() {
3737
System.out.println(x); // Prints 0 instead of the value of x
3838
}
3939
}
@@ -42,10 +42,10 @@ <h4>Compliant solution</h4>
4242
<pre data-diff-id="1" data-diff-type="compliant">
4343
class Super {
4444
Super() {
45-
overriddenMethod();
45+
foo();
4646
}
4747

48-
void overriddenMethod() {
48+
void foo() {
4949
System.out.println("Base logic");
5050
}
5151
}
@@ -59,21 +59,21 @@ <h4>Compliant solution</h4>
5959
}
6060

6161
@Override
62-
void overriddenMethod() {
62+
void foo() {
6363
System.out.println(x); // Prints the expected value
6464
}
6565
}
6666
</pre>
6767
<p>Alternatively, if the method in the superclass does not need to be overridden, it can be marked as <code>final</code> or <code>private</code> to
6868
prevent the issue entirely.</p>
6969
<h4>Noncompliant code example</h4>
70-
<pre data-diff-id="1" data-diff-type="noncompliant">
70+
<pre data-diff-id="2" data-diff-type="noncompliant">
7171
class Super {
7272
Super() {
73-
overriddenMethod();
73+
foo();
7474
}
7575

76-
void overriddenMethod() {
76+
void foo() {
7777
System.out.println("Base logic");
7878
}
7979
}
@@ -83,23 +83,23 @@ <h4>Noncompliant code example</h4>
8383

8484
Sub(int x) {
8585
super();
86-
this.x = x; // Noncompliant: x is uninitialized when overriddenMethod is called by Super()
86+
this.x = x; // Noncompliant: x is uninitialized when foo is called by Super()
8787
}
8888

8989
@Override
90-
void overriddenMethod() {
90+
void foo() {
9191
System.out.println(x); // Prints 0 instead of the value of x
9292
}
9393
}
9494
</pre>
9595
<h4>Compliant solution</h4>
96-
<pre data-diff-id="1" data-diff-type="compliant">
96+
<pre data-diff-id="2" data-diff-type="compliant">
9797
class Super {
9898
Super() {
99-
overriddenMethod();
99+
foo();
100100
}
101101

102-
final void finalMethod() {
102+
final void foo() {
103103
System.out.println("Base logic");
104104
}
105105
}
@@ -109,13 +109,13 @@ <h4>Compliant solution</h4>
109109

110110
Sub(int x) {
111111
super();
112-
this.x = x; // Compliant: finalMethod is final, so it cannot be overridden and will not access uninitialized fields
112+
this.x = x; // Compliant: foo is final, so it cannot be overridden and will not access uninitialized fields
113113
}
114114
}
115115
</pre>
116116
<h2>Resources</h2>
117117
<h3>Documentation</h3>
118118
<ul>
119-
<li> <a href="https://openjdk.org/jeps/513">JEP 513: Flexible Constructor Bodies</a> </li>
119+
<li><a href="https://openjdk.org/jeps/513">JEP 513: Flexible Constructor Bodies</a></li>
120120
</ul>
121121

sonarpedia.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"languages": [
44
"JAVA"
55
],
6-
"latest-update": "2026-02-26T08:20:43.956169Z",
6+
"latest-update": "2026-02-27T13:15:37.935044048Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": false
1010
}
11-
}
11+
}

0 commit comments

Comments
 (0)