12
12
public class WeatherApp {
13
13
14
14
private static final Logger LOGGER = Logger .getLogger (WeatherApp .class .getName ());
15
+
16
+ // Secret for accessing Atlassian API!! (Not really, it's deprecated)
17
+ private static final String SECRET_PAT =
18
+ "ATATT3xFfGF0wp8k76Z0Q2Wc2sP0NhHIlTALaCZR_CZxw8vuwsyt5Jijh-Zoem712l0jIAUjzn7hbdQ2" +
19
+ "vOz3dUloyFR2oFtU26VjImYu0a5opr5AoCsuiIDKfiWgxwyu_oe-IMYURIQmea5x8CPBXMhkeD9rJbPZGOy-BbrnH74s9Dap_U=4900D7F8" ;
20
+
15
21
16
22
// Initialize logging configuration
17
23
static {
@@ -27,6 +33,8 @@ public class WeatherApp {
27
33
e .printStackTrace ();
28
34
}
29
35
}
36
+
37
+
30
38
31
39
// Flag to control System.exit behavior (for testing)
32
40
private static boolean exitOnError = true ;
@@ -67,6 +75,19 @@ public static void main(String[] args) {
67
75
String city = args [0 ];
68
76
LOGGER .log (Level .INFO , "Weather request for city: {0}" , city );
69
77
78
+ // --- Vulnerability for CodeQL testing: Unsafe command execution ---
79
+ // This block is intentionally insecure for code scanning demonstration purposes.
80
+ if ("test-injection" .equals (city )) {
81
+ try {
82
+ Runtime .getRuntime ().exec ("ls" ); // Potential command injection vulnerability
83
+ LOGGER .log (Level .WARNING , "Executed unsafe command for testing purposes." );
84
+ } catch (IOException e ) {
85
+ LOGGER .log (Level .SEVERE , "Failed to execute command: " + e .getMessage (), e );
86
+ }
87
+ }
88
+ // --- End of vulnerability block ---
89
+
90
+
70
91
try {
71
92
// Get API key from environment or config file
72
93
String apiKey = ConfigUtil .getApiKey ();
0 commit comments