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

chore: testing sonarcloud scan for bugs. DO NOT MERGE #244

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions app/app/components/auth/sonarcloud-typescript-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is for testing the SonarCloud scan. Do not merge.

// HTTP request redirections should not be open to forging attacks
let server;
server.get("/redirect", (request, response) => {
response.redirect(request.query.url); // Noncompliant
});

// Types without members, 'any' and 'never' should not be used in type intersections
function foo(bar: String & null) {
// Noncompliant
if (bar) {
console.log("a");
}
}

foo(null);

// Jump statements should not occur in "finally" blocks
async function jump() {
let result, connection, connect;
try {
connection = await connect();
result = connection.send(1);
} catch (err) {
console.error(err.message); // if this line throws, this exception will not be propagated
} finally {
connection.close();
return result; // Noncompliant
}
}

jump();

export {};
18 changes: 18 additions & 0 deletions sonarcloud-kubernetes-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for testing the SonarCloud scan. Do not merge.

# Mounting sensitive file system paths is security-sensitive
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /data
name: test-volume
volumes:
- name: test-volume
hostPath:
path: /etc # Sensitive
33 changes: 33 additions & 0 deletions sonarcloud-python-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is for testing the SonarCloud scan. Do not merge.

# OS commands should not be vulnerable to command injection attacks
def ping():
cmd = "ping -c 1 %s" % request.args.get("host", "www.google.com")
status = os.system(cmd) # Noncompliant
return str(status == 0)

# Applications should not create session cookies from untrusted input
from django.shortcuts import render

def check_cookie(request):
response = render(request, "welcome.html")

if not "sessionid" in request.COOKIE:
cookie = request.GET.get("cookie")
response.set_cookie("sessionid", cookie) # Noncompliant

return response

# Assert should not be called on a tuple literal
def test_values(a, b):
assert (a, b) # Noncompliant

# Calls should not be made to non-callable values
class MyClass:
pass

myvar = MyClass()
myvar() # Noncompliant

none_var = None
none_var() # Noncompliant
19 changes: 19 additions & 0 deletions sonarcloud-sql-test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- This file is for testing the SonarCloud scan. Do not merge. --

-- Inserts should include values for non-null columns
INSERT INTO MY_TABLE -- Noncompliant; N2 value omitted
(
N1
)
VALUES
(
1
)

-- "DELETE" and "UPDATE" statements should contain "WHERE" clauses
DECLARE
maxAge PLS_INTEGER := 60;
BEGIN
UPDATE employee SET status = 'retired'; -- Noncompliant - the WHERE was forgotten
END;
/
20 changes: 20 additions & 0 deletions sonarcloud-terraform-test.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is for testing the SonarCloud scan. Do not merge.

# AWS IAM policies should not allow privilege escalation
resource "aws_iam_policy" "lambdaUpdatePolicy" {
name = "lambdaUpdatePolicy"
policy =<<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:UpdateFunctionCode"
],
"Resource": "*"
}
]
}
EOF
}