From 00fe4ff4a4119d94df2235b3a231a8800fdf625e Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Thu, 30 Nov 2023 16:18:30 +0100 Subject: [PATCH 01/20] Add secret example --- src/main/java/devoxx/SecretInJava.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/devoxx/SecretInJava.java diff --git a/src/main/java/devoxx/SecretInJava.java b/src/main/java/devoxx/SecretInJava.java new file mode 100644 index 0000000..f29faee --- /dev/null +++ b/src/main/java/devoxx/SecretInJava.java @@ -0,0 +1,10 @@ +package devoxx; + +import java.util.Properties; + +public class SecretInJava { + public static void main(String[] args) { + Properties props = new Properties(); + props.put("token", "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"); + } +} From b8be002fa3ef6d211264ca3a298139e4f71390d7 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Fri, 2 Feb 2024 08:51:23 +0100 Subject: [PATCH 02/20] Check something with IaC --- iac/Microsoft.Network_networkInterfaces.bicep | 31 ++++++++++++++++ iac/Microsoft.Network_networkInterfaces.json | 37 +++++++++++++++++++ iac/nocpu-limit.yaml | 11 ++++++ 3 files changed, 79 insertions(+) create mode 100644 iac/Microsoft.Network_networkInterfaces.bicep create mode 100644 iac/Microsoft.Network_networkInterfaces.json create mode 100644 iac/nocpu-limit.yaml diff --git a/iac/Microsoft.Network_networkInterfaces.bicep b/iac/Microsoft.Network_networkInterfaces.bicep new file mode 100644 index 0000000..080697a --- /dev/null +++ b/iac/Microsoft.Network_networkInterfaces.bicep @@ -0,0 +1,31 @@ +resource raiseAnIssue 'Microsoft.Network/networkInterfaces@2022-11-01' = { + name: 'Raise an issue' + properties: { + ipConfigurations: [ + { + properties: { + subnet: { + properties: { + networkSecurityGroup: { + properties: { + securityRules: [ + { + properties: { + // TODO fix me + direction: 'Inbound' + access: 'Allow' + protocol: 'TCP' + destinationPortRange: '*' + sourceAddressPrefix: '*' + } + } + ] + } + } + } + } + } + } + ] + } +} diff --git a/iac/Microsoft.Network_networkInterfaces.json b/iac/Microsoft.Network_networkInterfaces.json new file mode 100644 index 0000000..4bda06e --- /dev/null +++ b/iac/Microsoft.Network_networkInterfaces.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "name": "Raise an issue", + "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2022-11-01", + "properties": { + "ipConfigurations": [ + { + "properties": { + "subnet": { + "properties": { + "networkSecurityGroup": { + "properties": { + "securityRules": [ + { + "properties": { + "direction" : "Inbound", + "access" : "Allow", + "protocol" : "TCP", + "destinationPortRange" : "*", + "sourceAddressPrefix": "*" + } + } + ] + } + } + } + } + } + } + ] + } + } + ] +} diff --git a/iac/nocpu-limit.yaml b/iac/nocpu-limit.yaml new file mode 100644 index 0000000..98a0a49 --- /dev/null +++ b/iac/nocpu-limit.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Pod +metadata: + name: example +spec: + containers: + - name: noncompliant_without_cpu_limit + image: nginx + resources: + limits: + memory: 64Mi From 66165a552bf419ca23601acded8a2979a0a23511 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Fri, 2 Feb 2024 09:12:22 +0100 Subject: [PATCH 03/20] Add Iac code to java dir --- .../Microsoft.Network_networkInterfaces.bicep | 31 ++++++++++++++++ .../Microsoft.Network_networkInterfaces.json | 37 +++++++++++++++++++ src/main/java/nocpu-limit.yaml | 11 ++++++ 3 files changed, 79 insertions(+) create mode 100644 src/main/java/Microsoft.Network_networkInterfaces.bicep create mode 100644 src/main/java/Microsoft.Network_networkInterfaces.json create mode 100644 src/main/java/nocpu-limit.yaml diff --git a/src/main/java/Microsoft.Network_networkInterfaces.bicep b/src/main/java/Microsoft.Network_networkInterfaces.bicep new file mode 100644 index 0000000..080697a --- /dev/null +++ b/src/main/java/Microsoft.Network_networkInterfaces.bicep @@ -0,0 +1,31 @@ +resource raiseAnIssue 'Microsoft.Network/networkInterfaces@2022-11-01' = { + name: 'Raise an issue' + properties: { + ipConfigurations: [ + { + properties: { + subnet: { + properties: { + networkSecurityGroup: { + properties: { + securityRules: [ + { + properties: { + // TODO fix me + direction: 'Inbound' + access: 'Allow' + protocol: 'TCP' + destinationPortRange: '*' + sourceAddressPrefix: '*' + } + } + ] + } + } + } + } + } + } + ] + } +} diff --git a/src/main/java/Microsoft.Network_networkInterfaces.json b/src/main/java/Microsoft.Network_networkInterfaces.json new file mode 100644 index 0000000..4bda06e --- /dev/null +++ b/src/main/java/Microsoft.Network_networkInterfaces.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "name": "Raise an issue", + "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2022-11-01", + "properties": { + "ipConfigurations": [ + { + "properties": { + "subnet": { + "properties": { + "networkSecurityGroup": { + "properties": { + "securityRules": [ + { + "properties": { + "direction" : "Inbound", + "access" : "Allow", + "protocol" : "TCP", + "destinationPortRange" : "*", + "sourceAddressPrefix": "*" + } + } + ] + } + } + } + } + } + } + ] + } + } + ] +} diff --git a/src/main/java/nocpu-limit.yaml b/src/main/java/nocpu-limit.yaml new file mode 100644 index 0000000..98a0a49 --- /dev/null +++ b/src/main/java/nocpu-limit.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Pod +metadata: + name: example +spec: + containers: + - name: noncompliant_without_cpu_limit + image: nginx + resources: + limits: + memory: 64Mi From 4c2035784d24c24adacc5143d5f112c643754dcb Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Tue, 16 Apr 2024 10:50:59 +0200 Subject: [PATCH 04/20] Add ConstantExample --- src/main/java/devoxx/ConstantExample.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/devoxx/ConstantExample.java diff --git a/src/main/java/devoxx/ConstantExample.java b/src/main/java/devoxx/ConstantExample.java new file mode 100644 index 0000000..2ac698e --- /dev/null +++ b/src/main/java/devoxx/ConstantExample.java @@ -0,0 +1,11 @@ +package devoxx; + +import java.util.HashMap; +import java.util.Map; + +public class ConstantExample { + + private static final Map decoratorsOrder = new HashMap<>(); + + +} From 15ef989b39d51aa2277892ebc62d2c335ebc4a20 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Tue, 21 Jan 2025 16:47:46 +0100 Subject: [PATCH 05/20] Add If else if example --- src/main/java/devoxx/IfElseIfTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/devoxx/IfElseIfTest.java diff --git a/src/main/java/devoxx/IfElseIfTest.java b/src/main/java/devoxx/IfElseIfTest.java new file mode 100644 index 0000000..b585012 --- /dev/null +++ b/src/main/java/devoxx/IfElseIfTest.java @@ -0,0 +1,9 @@ +package devoxx; + +class IfElseIfTest { + if (true) { + System.out.println("x"); + } else if (true) { + throw new RuntimeException("boom"); + } +} From 5bf71cfed3e5ab5136aff8fdc7bdcaaa0d51ecc5 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Tue, 21 Jan 2025 16:52:44 +0100 Subject: [PATCH 06/20] Add If else if example 2 --- src/main/java/devoxx/IfElseIfTest.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/devoxx/IfElseIfTest.java b/src/main/java/devoxx/IfElseIfTest.java index b585012..f2bccf9 100644 --- a/src/main/java/devoxx/IfElseIfTest.java +++ b/src/main/java/devoxx/IfElseIfTest.java @@ -1,9 +1,25 @@ package devoxx; class IfElseIfTest { - if (true) { - System.out.println("x"); - } else if (true) { - throw new RuntimeException("boom"); + public static void main(String[] args) { + if (true) { + System.out.println("x"); + } else if (true) { + throw new RuntimeException("boom"); + } + + if (true) { + System.out.println("x"); + } else if (true) { + System.out.println("y"); + } + + if (true) { + System.out.println("x"); + } else if (true) { + System.out.println("y"); + } else { + System.out.println("z"); + } } } From 883ddd9deef325d33891a8911269961e80868b5d Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Tue, 21 Jan 2025 16:58:48 +0100 Subject: [PATCH 07/20] Add If else if example 3 --- src/main/java/devoxx/IfElseIfTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/devoxx/IfElseIfTest.java b/src/main/java/devoxx/IfElseIfTest.java index f2bccf9..8e72bec 100644 --- a/src/main/java/devoxx/IfElseIfTest.java +++ b/src/main/java/devoxx/IfElseIfTest.java @@ -2,21 +2,23 @@ class IfElseIfTest { public static void main(String[] args) { - if (true) { + boolean a = System.getProperty("x"); + boolean b = System.getProperty("y"); + if (a) { System.out.println("x"); - } else if (true) { + } else if (b) { throw new RuntimeException("boom"); } - if (true) { + if (a) { System.out.println("x"); - } else if (true) { + } else if (b) { System.out.println("y"); } - if (true) { + if (a) { System.out.println("x"); - } else if (true) { + } else if (b) { System.out.println("y"); } else { System.out.println("z"); From 7038bb0badf1183e75ceb7308c25c66ec7616239 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Wed, 19 Mar 2025 08:05:32 +0100 Subject: [PATCH 08/20] Add some Iac Files --- pom.xml | 4 +- src/main/java/devoxx/IfElseIfTest.java | 4 +- src/main/java/devoxx/Tree.java | 4 ++ src/main/java/devoxx/package-info.java | 3 + .../Microsoft.Network_networkInterfaces.bicep | 0 .../Microsoft.Network_networkInterfaces.json | 0 src/main/java/iac/S6273.tf | 9 +++ src/main/java/iac/S6573.dockerfile | 12 ++++ src/main/java/iac/ansible-S6868.yaml | 46 +++++++++++++ src/main/java/iac/cf-S6252.json | 69 +++++++++++++++++++ src/main/java/iac/cf-S6252.yaml | 52 ++++++++++++++ src/main/java/iac/micronaut-S3330.yaml | 19 +++++ src/main/java/{ => iac}/nocpu-limit.yaml | 0 src/main/java/iac/spring-S3330.yaml | 5 ++ 14 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 src/main/java/devoxx/Tree.java create mode 100644 src/main/java/devoxx/package-info.java rename src/main/java/{ => iac}/Microsoft.Network_networkInterfaces.bicep (100%) rename src/main/java/{ => iac}/Microsoft.Network_networkInterfaces.json (100%) create mode 100644 src/main/java/iac/S6273.tf create mode 100644 src/main/java/iac/S6573.dockerfile create mode 100644 src/main/java/iac/ansible-S6868.yaml create mode 100644 src/main/java/iac/cf-S6252.json create mode 100644 src/main/java/iac/cf-S6252.yaml create mode 100644 src/main/java/iac/micronaut-S3330.yaml rename src/main/java/{ => iac}/nocpu-limit.yaml (100%) create mode 100644 src/main/java/iac/spring-S3330.yaml diff --git a/pom.xml b/pom.xml index 5894eb4..4da772a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,8 @@ 1.0-SNAPSHOT src/main/java,src/main/javascript - 1.8 - 1.8 + 17 + 17 sonarwearedevelopersdemo https://sonarcloud.io diff --git a/src/main/java/devoxx/IfElseIfTest.java b/src/main/java/devoxx/IfElseIfTest.java index 8e72bec..c8437f4 100644 --- a/src/main/java/devoxx/IfElseIfTest.java +++ b/src/main/java/devoxx/IfElseIfTest.java @@ -2,8 +2,8 @@ class IfElseIfTest { public static void main(String[] args) { - boolean a = System.getProperty("x"); - boolean b = System.getProperty("y"); + boolean a = System.getenv().containsKey("x"); + boolean b = System.getenv().containsKey("y"); if (a) { System.out.println("x"); } else if (b) { diff --git a/src/main/java/devoxx/Tree.java b/src/main/java/devoxx/Tree.java new file mode 100644 index 0000000..ba4f77d --- /dev/null +++ b/src/main/java/devoxx/Tree.java @@ -0,0 +1,4 @@ +package devoxx; + +public class Tree { +} diff --git a/src/main/java/devoxx/package-info.java b/src/main/java/devoxx/package-info.java new file mode 100644 index 0000000..efa201b --- /dev/null +++ b/src/main/java/devoxx/package-info.java @@ -0,0 +1,3 @@ + +@javax.annotation.ParametersAreNonnullByDefault +package devoxx; diff --git a/src/main/java/Microsoft.Network_networkInterfaces.bicep b/src/main/java/iac/Microsoft.Network_networkInterfaces.bicep similarity index 100% rename from src/main/java/Microsoft.Network_networkInterfaces.bicep rename to src/main/java/iac/Microsoft.Network_networkInterfaces.bicep diff --git a/src/main/java/Microsoft.Network_networkInterfaces.json b/src/main/java/iac/Microsoft.Network_networkInterfaces.json similarity index 100% rename from src/main/java/Microsoft.Network_networkInterfaces.json rename to src/main/java/iac/Microsoft.Network_networkInterfaces.json diff --git a/src/main/java/iac/S6273.tf b/src/main/java/iac/S6273.tf new file mode 100644 index 0000000..5fe1243 --- /dev/null +++ b/src/main/java/iac/S6273.tf @@ -0,0 +1,9 @@ +resource "aws_s3_bucket" "myawsbucket" { + tags = { + "anycompany:cost-center" = "" # Noncompliant (S6273) + "anycompany:CostCenter" = "" # Noncompliant + "AnyCompany:CostCenter:Bar" = "" + } + + tags = { "anycompany:CostCenter" = "" } # No valid syntax to have more than one tag statement +} diff --git a/src/main/java/iac/S6573.dockerfile b/src/main/java/iac/S6573.dockerfile new file mode 100644 index 0000000..f65c9e4 --- /dev/null +++ b/src/main/java/iac/S6573.dockerfile @@ -0,0 +1,12 @@ +FROM scratch + +RUN rm -rf * +RUN tar xfv *.tar + +ARG FOO +# Compliant - rule shouldn't be checking asterisks inside a quoted string +RUN echo "* * * * * echo $FOO; ./cron-job" >> /etc/crontabs +RUN echo "rm *" >> ~/.forbidden-commands + +RUN rm -rf -- * +RUN tar xfv ./*.tar diff --git a/src/main/java/iac/ansible-S6868.yaml b/src/main/java/iac/ansible-S6868.yaml new file mode 100644 index 0000000..9fd5ae6 --- /dev/null +++ b/src/main/java/iac/ansible-S6868.yaml @@ -0,0 +1,46 @@ +--- +- name: K8s command execution tasks + hosts: all + tasks: + - name: Role Example + kubernetes.core.k8s: + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: Role + metadata: + namespace: default + name: noncompliant-role + rules: + - apiGroups: [ "" ] + resources: [ "pods/exec" ] # Noncompliant + verbs: [ "create" ] + + - apiGroups: [ "" ] + resources: [ "*" ] # Noncompliant + verbs: [ "create" ] + + - apiGroups: [ "" ] + resources: [ "services" ] # Compliant + verbs: [ "create" ] + - name: ClusterRole Example + kubernetes.core.k8s: + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: ClusterRole + metadata: + namespace: default + name: noncompliant-role + rules: + - apiGroups: [ "" ] + resources: [ "*" ] # Noncompliant + verbs: [ "*" ] + + - apiGroups: [ "" ] + resources: [ "pods/exec" ] # Noncompliant + verbs: [ "*" ] + + - apiGroups: [ "" ] + resources: [ "pods/exec" ] # Compliant + verbs: [ "get" ] diff --git a/src/main/java/iac/cf-S6252.json b/src/main/java/iac/cf-S6252.json new file mode 100644 index 0000000..c7337c6 --- /dev/null +++ b/src/main/java/iac/cf-S6252.json @@ -0,0 +1,69 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09T00:00:00.000Z", + "Resources": { + "S3BucketEnabledVersioning": { + "Type": "AWS::S3::Bucket", + "Properties": { + "VersioningConfiguration": { + "Status": "Enabled" + } + } + }, + "S3BucketEnabledVersioning2": { + "Type": "AWS::S3::Bucket", + "Properties": { + "VersioningConfiguration": { + "Status": "Enabled" + } + } + }, + "S3BucketSupendedVersioning": { + "Type": "AWS::S3::Bucket", + "Properties": { + "VersioningConfiguration": { + "Status": "Suspended" + } + } + }, + "S3BucketWithoutVersioning": { + "Type": "AWS::S3::Bucket", + "Properties": { + "VersioningConfiguration": { + "Foo": "Enabled" + } + } + }, + "S3BucketUnkownVersioning": { + "Type": "AWS::S3::Bucket", + "Properties": { + "VersioningConfiguration": { + "Status": "GlobalBucketVersioning" + } + } + }, + "S3BucketShortNotation": { + "Type": "AWS::S3::Bucket", + "VersioningConfiguration.Status": "Enabled" + }, + "BucketWithNoPropertiesSet": { + "Type": "AWS::S3::Bucket" + }, + "NoBucket": { + "Type": "Not a Bucket", + "Properties": { + "name": "not a bucket" + } + }, + "NoBucket2": { + "Properties": { + "name": "not a bucket" + } + }, + "NoBucket3": { + "Type": [], + "Properties": { + "name": "not a bucket" + } + } + } +} diff --git a/src/main/java/iac/cf-S6252.yaml b/src/main/java/iac/cf-S6252.yaml new file mode 100644 index 0000000..2f06a6e --- /dev/null +++ b/src/main/java/iac/cf-S6252.yaml @@ -0,0 +1,52 @@ +AWSTemplateFormatVersion: 2010-09-09 +Resources: + S3BucketEnabledVersioning: + Type: 'AWS::S3::Bucket' + Properties: + VersioningConfiguration: + Status: Enabled + + S3BucketEnabledVersioning2: + Type: 'AWS::S3::Bucket' + Properties: + VersioningConfiguration: {Status: Enabled} + + S3BucketSupendedVersioning: + Type: 'AWS::S3::Bucket' + Properties: + VersioningConfiguration: + Status: Suspended # Noncompliant {{Make sure using suspended versioned S3 bucket is safe here.}} +# ^^^^^^^^^ + + S3BucketWithoutVersioning: + Type: 'AWS::S3::Bucket' + Properties: + VersioningConfiguration: # Noncompliant {{Make sure using unversioned S3 bucket is safe here.}} + Foo: Enabled + + S3BucketUnkownVersioning: + Type: 'AWS::S3::Bucket' + Properties: + VersioningConfiguration: + Status: !Ref GlobalBucketVersioning + + S3BucketShortNotation: + Type: 'AWS::S3::Bucket' # Noncompliant + VersioningConfiguration.Status: Enabled + + BucketWithNoPropertiesSet: + Type: 'AWS::S3::Bucket' # Noncompliant + + NoBucket: + Type: 'Not a Bucket' + Properties: + name: "not a bucket" + + NoBucket2: + Properties: + name: "not a bucket" + + NoBucket3: + Type: [] + Properties: + name: "not a bucket" diff --git a/src/main/java/iac/micronaut-S3330.yaml b/src/main/java/iac/micronaut-S3330.yaml new file mode 100644 index 0000000..ce81c57 --- /dev/null +++ b/src/main/java/iac/micronaut-S3330.yaml @@ -0,0 +1,19 @@ +micronaut: + security: + token: + cookie: + cookie-http-only: false + jwt: + cookie: + cookie-http-only: false + refresh: + cookie: + cookie-http-only: false + oauth2: + openid: + nonce: + cookie: + cookie-http-only: false + state: + cookie: + cookie-http-only: false diff --git a/src/main/java/nocpu-limit.yaml b/src/main/java/iac/nocpu-limit.yaml similarity index 100% rename from src/main/java/nocpu-limit.yaml rename to src/main/java/iac/nocpu-limit.yaml diff --git a/src/main/java/iac/spring-S3330.yaml b/src/main/java/iac/spring-S3330.yaml new file mode 100644 index 0000000..56e31b1 --- /dev/null +++ b/src/main/java/iac/spring-S3330.yaml @@ -0,0 +1,5 @@ +server: + servlet: + session: + cookie: + http-only: false From 1dbb3f2c7cde19fa29fb5c154679714305e2b41a Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Thu, 20 Mar 2025 17:14:41 +0100 Subject: [PATCH 09/20] Add secret --- src/main/java/secrets/conf.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/secrets/conf.conf diff --git a/src/main/java/secrets/conf.conf b/src/main/java/secrets/conf.conf new file mode 100644 index 0000000..152fdb6 --- /dev/null +++ b/src/main/java/secrets/conf.conf @@ -0,0 +1,6 @@ +# Test case from pubkey-crypto.yaml to show that there is no overlap +-----BEGIN PRIVATE KEY----- +MG8CAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQEEVTBTAgEBBBiYwF7DmgkMs5nuBTGo +qStzE1qIw4I8oR6hNAMyAARglVCk/eB1iMoPWZO+GyLAdpb7PykKintU3m9cS8cN +/I3gU7NXutYjL9npMWLoHPI= +-----END PRIVATE KEY----- From 0e82eb28facce0f24b9378b524e93e28456eb995 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 29 Sep 2025 21:02:14 +0200 Subject: [PATCH 10/20] Add Go file to test NOSONAR --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..c85ae04 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +func main() { + //NOSONAR + //TODO fix me + fmt.Println("Hello") +} From af2d3884c93c15b047cee00178c43cad073ea307 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 29 Sep 2025 21:08:21 +0200 Subject: [PATCH 11/20] Move main.go file --- src/main/java/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/main.go diff --git a/src/main/java/main.go b/src/main/java/main.go new file mode 100644 index 0000000..c85ae04 --- /dev/null +++ b/src/main/java/main.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +func main() { + //NOSONAR + //TODO fix me + fmt.Println("Hello") +} From 9e8ec1edc4fcb396a5afa4b9b666e66ff2240ad9 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 27 Oct 2025 15:58:58 +0100 Subject: [PATCH 12/20] Add check.sh --- check.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 check.sh diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..17ad192 --- /dev/null +++ b/check.sh @@ -0,0 +1,26 @@ +#!/bin/bash + patterns=( + '^.*\/src\/main\/resources\/org\/sonar\/l10n\/[^\/]+\/rules\/.*$' + '^.*\/src\/main\/resources\/com\/sonar\/l10n\/[^\/]+\/rules\/.*$' + '^.*sonarpedia\.json$' + '^.*\.md$' + ) + changed_files=$(git diff --name-only origin/master) + for file in $changed_files; do + matched=false + for pattern in "${patterns[@]}"; do + if [[ $file =~ $pattern ]]; then + matched=true + break + fi + done + if [[ $matched == false ]]; then + echo "File '$file' does not match metadata patterns." + break + fi + done + if [[ $matched == false ]]; then + echo "All jobs will be executed" + else + echo "The changes contains only metadata files. The QA jobs will be skipped." + fi From 4921cf07dfc3775c4701ceb5153d70527a274900 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 27 Oct 2025 16:01:38 +0100 Subject: [PATCH 13/20] Add Readme --- Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..345e6ae --- /dev/null +++ b/Readme.md @@ -0,0 +1 @@ +Test From f68a20c4f73d85168f5a2c4fd3e40b6c43aff40e Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 27 Oct 2025 16:02:00 +0100 Subject: [PATCH 14/20] Add Foo.java --- Foo.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 Foo.java diff --git a/Foo.java b/Foo.java new file mode 100644 index 0000000..4e6a6de --- /dev/null +++ b/Foo.java @@ -0,0 +1 @@ +class Foo {} From 6d3b4b4a908e78de22cf4f8127806c6a0a0c7a1c Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 22 Dec 2025 15:11:54 +0100 Subject: [PATCH 15/20] Test actions/upload-artifact --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c8de44..2390b61 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,11 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 #v4.3.3 + with: + path: | + **/.git/HEAD + - name: Set up JDK 11 uses: actions/setup-java@v1 with: @@ -33,4 +38,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=SonarWeAreDevelopersDemo_java-demo-1 \ No newline at end of file + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=SonarWeAreDevelopersDemo_java-demo-1 From 373ad9fbf0d40c7999b5d08e5bd4444285d03fad Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 22 Dec 2025 15:13:34 +0100 Subject: [PATCH 16/20] Test actions/upload-artifact 2 --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2390b61..2eeabe6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 #v4.3.3 @@ -18,12 +18,19 @@ jobs: path: | **/.git/HEAD + - name: Debug + run: | + echo "Listing .git directory contents:" + ls -la .git + echo "Displaying .git/HEAD contents:" + cat .git/HEAD + - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 11 - name: Cache SonarCloud packages - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar From da830e002eeceb4943def6ed9e47b4792c1d93a6 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Mon, 22 Dec 2025 15:14:13 +0100 Subject: [PATCH 17/20] Test actions/upload-artifact 3 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2eeabe6..e60428a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache Maven packages - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} From cc16bca310fb8b81a968c95a4730e700b020c407 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Tue, 23 Dec 2025 16:24:08 +0100 Subject: [PATCH 18/20] Test another pattern --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e60428a..efc3088 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,8 @@ jobs: - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 #v4.3.3 with: path: | - **/.git/HEAD + !.git/HEAD + .git/HEAD - name: Debug run: | From 1d92cddd74623901caee708a08a6a62140875976 Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Tue, 23 Dec 2025 16:25:54 +0100 Subject: [PATCH 19/20] Test another pattern 2 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efc3088..77b3985 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,8 +16,8 @@ jobs: - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 #v4.3.3 with: path: | - !.git/HEAD .git/HEAD + !.git/HEAD - name: Debug run: | From 4fc17ba12d9ef0852591f4b40c13c7bedd5082ee Mon Sep 17 00:00:00 2001 From: Marcin Stachniuk Date: Thu, 13 Aug 2026 17:26:11 +0200 Subject: [PATCH 20/20] Add 2 secrets --- src/main/java/devoxx/SecretInJava.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/devoxx/SecretInJava.java b/src/main/java/devoxx/SecretInJava.java index f29faee..e4b552f 100644 --- a/src/main/java/devoxx/SecretInJava.java +++ b/src/main/java/devoxx/SecretInJava.java @@ -6,5 +6,12 @@ public class SecretInJava { public static void main(String[] args) { Properties props = new Properties(); props.put("token", "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"); + + // S8135 + props.set("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoicm9vdCIsImZsYWciOiJoZWxsbyB3b3JsZCJ9.Fj8Y7ZGSLtNMyAkqGKWddRg3ZvwOpOTvRK7rHl4RWt4") + + // S8136 + String a = "Authorization: Basic dXNlcm5hbWU6OGZLejJwUTltTHg0" + } }