Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CodeQL rule ID for stack-trace-exposure #440

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@
import io.codemodder.providers.sarif.codeql.ProvidedCodeQLScan;
import javax.inject.Inject;

/** Fixes issues reported under the id "java/stack-trace-exposure" */
/**
* Fixes issues reported under the id "java/java-error-message-exposure" (used to be
* java-stack-trace-exposure).
*/
@Codemod(
id = "codeql:java/stack-trace-exposure",
id = "codeql:java/error-message-exposure",
reviewGuidance = ReviewGuidance.MERGE_WITHOUT_REVIEW,
importance = Importance.MEDIUM,
executionPriority = CodemodExecutionPriority.HIGH)
public final class StackTraceExposureCodemod extends CodeQLSarifJavaParserChanger<Expression> {

@Inject
public StackTraceExposureCodemod(
@ProvidedCodeQLScan(ruleId = "java/stack-trace-exposure") final RuleSarif sarif) {
@ProvidedCodeQLScan(ruleId = "java/error-message-exposure") final RuleSarif sarif) {
super(sarif, Expression.class, SourceCodeRegionExtractor.FROM_SARIF_FIRST_LOCATION);
}

Expand Down Expand Up @@ -57,8 +60,8 @@ public ChangesResult onResultFound(
@Override
public DetectorRule detectorRule() {
return new DetectorRule(
"stack-trace-exposure",
"error-message-exposure",
"Prevent information leak of stack trace details to HTTP responses",
"https://codeql.github.com/codeql-query-help/java/java-stack-trace-exposure/");
"https://codeql.github.com/codeql-query-help/java/java-error-message-exposure/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"change": "Removed the argument which would end up exposed in the HTTP response and leak implementation details of our application to the user",
"reviewGuidanceJustification" : "This codemod prevents internal coding details from reaching the HTTP response body, and we believe that fixing it presents zero risk.",
"references" : [
"https://codeql.github.com/codeql-query-help/java/java-stack-trace-exposure/",
"https://codeql.github.com/codeql-query-help/java/java-error-message-exposure/",
"https://cwe.mitre.org/data/definitions/209.html",
"https://cwe.mitre.org/data/definitions/497.html"
]
Expand Down
12 changes: 6 additions & 6 deletions core-codemods/src/test/resources/stack-trace-exposure/out.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
}
} ],
"results" : [ {
"ruleId" : "java/stack-trace-exposure",
"ruleId" : "java/error-message-exposure",
"ruleIndex" : 0,
"rule" : {
"id" : "java/stack-trace-exposure",
"id" : "java/error-message-exposure",
"index" : 0
},
"message" : {
Expand Down Expand Up @@ -116,10 +116,10 @@
}
} ]
}, {
"ruleId" : "java/stack-trace-exposure",
"ruleId" : "java/error-message-exposure",
"ruleIndex" : 0,
"rule" : {
"id" : "java/stack-trace-exposure",
"id" : "java/error-message-exposure",
"index" : 0
},
"message" : {
Expand Down Expand Up @@ -162,10 +162,10 @@
}
} ]
}, {
"ruleId" : "java/stack-trace-exposure",
"ruleId" : "java/error-message-exposure",
"ruleIndex" : 0,
"rule" : {
"id" : "java/stack-trace-exposure",
"id" : "java/error-message-exposure",
"index" : 0
},
"message" : {
Expand Down
Loading