Skip to content

Commit 7824c7a

Browse files
Merge pull request #5 from EficodeDemoOrg/secretdemo
Inject vulns
2 parents 0b765c1 + 72b7f9e commit 7824c7a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/java/com/weather/app/WeatherApp.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
public class WeatherApp {
1313

1414
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+
1521

1622
// Initialize logging configuration
1723
static {
@@ -27,6 +33,8 @@ public class WeatherApp {
2733
e.printStackTrace();
2834
}
2935
}
36+
37+
3038

3139
// Flag to control System.exit behavior (for testing)
3240
private static boolean exitOnError = true;
@@ -67,6 +75,19 @@ public static void main(String[] args) {
6775
String city = args[0];
6876
LOGGER.log(Level.INFO, "Weather request for city: {0}", city);
6977

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+
7091
try {
7192
// Get API key from environment or config file
7293
String apiKey = ConfigUtil.getApiKey();

0 commit comments

Comments
 (0)