fix: challenge 7 (#1433)
This commit is contained in:
@ -32,6 +32,4 @@ public interface SolutionConstants {
|
||||
|
||||
// TODO should be random generated when starting the server
|
||||
String PASSWORD = "!!webgoat_admin_1234!!";
|
||||
String PASSWORD_TOM = "thisisasecretfortomonly";
|
||||
String ADMIN_PASSWORD_LINK = "375afe1104f4a487a73823c50a9292a2";
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import org.owasp.webgoat.container.assignments.AssignmentEndpoint;
|
||||
import org.owasp.webgoat.container.assignments.AttackResult;
|
||||
import org.owasp.webgoat.lessons.challenges.Email;
|
||||
import org.owasp.webgoat.lessons.challenges.Flags;
|
||||
import org.owasp.webgoat.lessons.challenges.SolutionConstants;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -32,6 +31,8 @@ import org.springframework.web.client.RestTemplate;
|
||||
@Slf4j
|
||||
public class Assignment7 extends AssignmentEndpoint {
|
||||
|
||||
public static final String ADMIN_PASSWORD_LINK = "375afe1104f4a487a73823c50a9292a2";
|
||||
|
||||
private static final String TEMPLATE =
|
||||
"Hi, you requested a password reset link, please use this <a target='_blank'"
|
||||
+ " href='%s:8080/WebGoat/challenge/7/reset-password/%s'>link</a> to reset your"
|
||||
@ -56,15 +57,13 @@ public class Assignment7 extends AssignmentEndpoint {
|
||||
|
||||
@GetMapping("/challenge/7/reset-password/{link}")
|
||||
public ResponseEntity<String> resetPassword(@PathVariable(value = "link") String link) {
|
||||
if (link.equals(SolutionConstants.ADMIN_PASSWORD_LINK)) {
|
||||
if (link.equals(ADMIN_PASSWORD_LINK)) {
|
||||
return ResponseEntity.accepted()
|
||||
.body(
|
||||
"<h1>Success!!</h1>"
|
||||
+ "<img src='/WebGoat/images/hi-five-cat.jpg'>"
|
||||
+ "<br/><br/>Here is your flag: "
|
||||
+ "<b>"
|
||||
+ flags.getFlag(7)
|
||||
+ "</b>");
|
||||
+ flags.getFlag(7));
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.I_AM_A_TEAPOT)
|
||||
.body("That is not the reset link for admin");
|
||||
@ -99,6 +98,6 @@ public class Assignment7 extends AssignmentEndpoint {
|
||||
@GetMapping(value = "/challenge/7/.git", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@ResponseBody
|
||||
public ClassPathResource git() {
|
||||
return new ClassPathResource("challenge7/git.zip");
|
||||
return new ClassPathResource("lessons/challenges/challenge7/git.zip");
|
||||
}
|
||||
}
|
||||
|
@ -23,26 +23,27 @@
|
||||
package org.owasp.webgoat.webwolf.mailbox;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class MailboxController {
|
||||
|
||||
private final MailboxRepository mailboxRepository;
|
||||
|
||||
@GetMapping(value = "/mail")
|
||||
@GetMapping("/mail")
|
||||
public ModelAndView mail() {
|
||||
UserDetails user =
|
||||
(UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
@ -56,9 +57,15 @@ public class MailboxController {
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/mail")
|
||||
public ResponseEntity<?> sendEmail(@RequestBody Email email) {
|
||||
@PostMapping("/mail")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public void sendEmail(@RequestBody Email email) {
|
||||
mailboxRepository.save(email);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).build();
|
||||
}
|
||||
|
||||
@DeleteMapping("/mail")
|
||||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
public void deleteAllMail() {
|
||||
mailboxRepository.deleteAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user