Skip to content

Commit

Permalink
auto discovery on SCA after adding repository
Browse files Browse the repository at this point in the history
  • Loading branch information
siewer committed Jul 28, 2024
1 parent 4e64d1b commit 7687e99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.security.Principal;
import java.security.*;
import java.security.cert.CertificateException;
import java.util.List;
import java.util.Optional;

Expand All @@ -38,7 +39,7 @@ public class OperateOnAssets {

@PreAuthorize("hasAuthority('ROLE_PROJECT_OWNER')")
@PostMapping("/create/project/{id}")
public ResponseEntity<?> processAsset(@RequestBody String json, @PathVariable("id") Long id, Principal principal) throws IOException {
public ResponseEntity<?> processAsset(@RequestBody String json, @PathVariable("id") Long id, Principal principal) throws IOException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Optional<Project> project = findProjectService.findProjectById(id);
if(project.isPresent() && permissionFactory.canUserAccessProject(principal, project.get())) {
JsonNode rootNode = objectMapper.readTree(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
import io.mixeway.domain.service.scanmanager.webapp.UpdateWebAppService;
import io.mixeway.domain.service.vulnhistory.OperateOnVulnHistoryService;
import io.mixeway.domain.service.vulnmanager.VulnTemplate;
import io.mixeway.scanmanager.service.opensource.OpenSourceScanService;
import io.mixeway.utils.PermissionFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.security.Principal;
import java.io.IOException;
import java.security.*;
import java.security.cert.CertificateException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
Expand Down Expand Up @@ -58,11 +61,15 @@ public class OperateOnAssetsService {
private final FindCiOperationsService findCiOperationsService;
private final GetAssetDashboardService getAssetDashboardService;
private final FindAssetHistoryService findAssetHistoryService;
private final OpenSourceScanService openSourceScanService;

public CodeProject createCodeProject(JsonNode rootNode, Project project, Principal principal) {
public CodeProject createCodeProject(JsonNode rootNode, Project project, Principal principal) throws UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, KeyManagementException {
String repositoryType = rootNode.path("repositoryType").asText();
if (repositoryType.equals("single")) {
return createSingleCodeProject(rootNode, project, principal);
CodeProject codeProject = createSingleCodeProject(rootNode, project, principal);
openSourceScanService.createProjectOnOpenSourceScanner(codeProject);

return codeProject;
} else if (repositoryType.equals("multiple")) {
return createMultipleCodeProject(rootNode, project, principal);
}
Expand Down

0 comments on commit 7687e99

Please sign in to comment.