forked from Sonar-Demos/java-security-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
New changes 20260122 #7
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
Open
jonathanvila
wants to merge
12
commits into
main
Choose a base branch
from
20260122
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b6c7eae
New changes
jonathanvila 8ec832f
New changes
jonathanvila 1966cc6
New changes
jonathanvila 6c92459
New changes
jonathanvila 2e6dd62
New changes
jonathanvila c331952
New changes
jonathanvila b7d457e
New changes
jonathanvila 74a7201
New changes
jonathanvila c64d087
New changes
jonathanvila 9580fd1
New changes
jonathanvila 5f83412
New changes
jonathanvila 2ff7f90
New changes
jonathanvila File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,8 +39,9 @@ public DBUtils() throws SQLException { | |
| } | ||
|
|
||
| public void newConnect() throws SQLException { | ||
| String myJDBCPasswd = "myJDBCPasswd"; | ||
| connection = DriverManager.getConnection( | ||
| "mYJDBCUrl", "myJDBCUser", "myJDBCPasswd"); | ||
| "mYJDBCUrl", "myJDBCUser", myJDBCPasswd); | ||
Check failureCode scanning / SonarCloud Credentials should not be hard-coded High
Revoke and change this password, as it is compromised. See more on SonarQube Cloud
|
||
|
|
||
| ArrayList<String> list = new ArrayList<>(); | ||
| list.add("hola"); | ||
|
|
@@ -62,16 +63,6 @@ public List<String> findUsers(String user) throws Exception { | |
| return users; | ||
| } | ||
|
|
||
| public List<String> findItem(String itemId) throws Exception { | ||
| String query = "SELECT item_id FROM items WHERE item_id = '" + itemId + "'"; | ||
| Statement statement = connection.createStatement(); | ||
| ResultSet resultSet = statement.executeQuery(query); | ||
| List<String> items = new ArrayList<String>(); | ||
| while (resultSet.next()) { | ||
| items.add(resultSet.getString(0)); | ||
| } | ||
| return items; | ||
| } | ||
|
|
||
| public void sumNumbers(int max) { | ||
| int count, sum = 0; | ||
|
|
@@ -96,39 +87,5 @@ public void sumNumbers(int max) { | |
| System.out.println("The Sum of numbers is: " + sum); | ||
| } | ||
|
|
||
| /** | ||
| * Connects to the given external URL 1000 times using threads. | ||
| * Each thread performs a single connection and logs the response code. | ||
| * | ||
| * @param urlString the external URL to connect to | ||
| */ | ||
| public static void connectToExternalUrlConcurrently(String urlString) { | ||
| final int THREAD_COUNT = 1000; | ||
| Thread[] threads = new Thread[THREAD_COUNT]; | ||
| for (int i = 0; i < THREAD_COUNT; i++) { | ||
| threads[i] = Thread.ofVirtual().unstarted(() -> { | ||
| try { | ||
| URL url = new URL(urlString); | ||
| HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||
| conn.setRequestMethod("GET"); | ||
| conn.setConnectTimeout(5000); | ||
| conn.setReadTimeout(5000); | ||
| int responseCode = conn.getResponseCode(); | ||
| conn.disconnect(); | ||
| } catch (Exception e) { | ||
| } | ||
| }); | ||
| } | ||
| for (Thread thread : threads) { | ||
| thread.start(); | ||
| } | ||
| for (Thread thread : threads) { | ||
| try { | ||
| thread.join(); | ||
| } catch (InterruptedException e) { | ||
| Thread.currentThread().interrupt(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / SonarCloud
Credentials should not be hard-coded