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: add vulnerable code #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,33 @@

@GetMapping("/posts")
public Collection<Post> posts() {
log.info("{}: recieved a GET request", deploymentType);
log.info("{}: received a GET request", deploymentType);
return repository.findAll().stream().collect(Collectors.toList());
}

@PostMapping("/posts")
public Post post(@RequestBody Post post, HttpServletResponse resp) {
log.info("{}: recieved a POST request", deploymentType);
log.info("{}: received a POST request", deploymentType);
return repository.save(post);
}

@DeleteMapping("/posts/{id}")
public void deletePost(@PathVariable("id") String id) {
log.info("{}: recieved a DELETE request", deploymentType);
log.info("{}: received a DELETE request", deploymentType);
repository.deleteById(Long.parseLong(id));
}

@GetMapping("/posts/{id}")
public Post getPostById(@PathVariable("id") String id) {
log.info("{}: received a GET request for post with id {}", deploymentType, id);

Check failure

Code scanning / CodeQL

Log Injection High

This log entry depends on a
user-provided value
.
return repository.findById(Long.parseLong(id)).orElse(null);
}

@GetMapping("/posts/search")
public Collection<Post> searchPosts(@RequestParam("query") String query) {
log.info("{}: received a GET request to search posts with query: {}", deploymentType, query);

Check failure

Code scanning / CodeQL

Log Injection High

This log entry depends on a
user-provided value
.
// WARNING: This code is vulnerable to SQL injection
String sql = "SELECT * FROM posts WHERE title LIKE '%" + query + "%'";
return repository.search(sql);
}
}
Loading