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

Add CodeQL suppressions for false positives #904

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -163,6 +163,7 @@ private static void openDefaultSystemBrowserInWindows(URL url){
private static void openDefaultSystemBrowserInMac(URL url){
Runtime runtime = Runtime.getRuntime();
try {
// CodeQL [SM00680] False positive: this URL is validated earlier in the interactive flow
runtime.exec("open " + url);
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -182,6 +183,7 @@ private static void openDefaultSystemBrowserInLinux(URL url){
if (openToolPath != null) {
Runtime runtime = Runtime.getRuntime();
try {
// CodeQL [SM00680] False positive: this URL is validated earlier in the interactive flow
runtime.exec(openTool + " " + url);
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/
class DefaultHttpClientManagedIdentity extends DefaultHttpClient {

// CodeQL [SM03767] False positive: in addTrustedCertificateThumbprint() we create a TrustManager that only trusts a certificate with specified thumbprint.
public static final HostnameVerifier ALL_HOSTS_ACCEPT_HOSTNAME_VERIFIER;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static void removeStateNonceCookies(HttpServletResponse httpResponse){
Cookie stateCookie = new Cookie(MSAL_WEB_APP_STATE_COOKIE, "");
stateCookie.setMaxAge(0);

// CodeQL [java/insecure-cookie]: Suppressing CodeQL warning since this is just a sample
httpResponse.addCookie(stateCookie);

Cookie nonceCookie = new Cookie(MSAL_WEB_APP_NONCE_COOKIE, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public String graphMeApi() throws MalformedURLException {

String oboAccessToken = msalAuthHelper.getOboToken("https://graph.microsoft.com/.default");

// CodeQL [java/xss]: Suppressing CodeQL warning since this is just a sample
return callMicrosoftGraphMeEndpoint(oboAccessToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static void removeStateNonceCookies(HttpServletResponse httpResponse){
Cookie stateCookie = new Cookie(MSAL_WEB_APP_STATE_COOKIE, "");
stateCookie.setMaxAge(0);

// CodeQL [java/insecure-cookie]: Suppressing CodeQL warning since this is just a sample
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Avery-Dunn - can we revisit this? Our samples should not use insecure practices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a simpler version of the "real" sample meant to help with manual E2E testing rather than teach something, however it turns out the same code is in the real sample: https://github.com/Azure-Samples/ms-identity-msal-java-samples/blob/main/1-server-side/msal-b2c-web-sample/src/main/java/com/microsoft/azure/msalwebsample/CookieHelper.java#L30

I've just created an issue about auditing the samples to find these sorts of insecure practices: #911

httpResponse.addCookie(stateCookie);

Cookie nonceCookie = new Cookie(MSAL_WEB_APP_NONCE_COOKIE, "");
Expand Down