diff --git a/lang-java/src/main/java/org/eclipse/steady/java/JarWriter.java b/lang-java/src/main/java/org/eclipse/steady/java/JarWriter.java index 421584650..407849e11 100644 --- a/lang-java/src/main/java/org/eclipse/steady/java/JarWriter.java +++ b/lang-java/src/main/java/org/eclipse/steady/java/JarWriter.java @@ -543,6 +543,7 @@ public Path rewrite(Path _todir) throws JarAnalysisException { } // Add additional files + for (Map.Entry e : this.additionalFiles.entrySet()) { if (e.getValue().toFile().exists()) { new_entry = new JarEntry(e.getKey()); diff --git a/lang-java/src/main/java/org/eclipse/steady/java/sign/gson/ASTSignatureChangeSerializer.java b/lang-java/src/main/java/org/eclipse/steady/java/sign/gson/ASTSignatureChangeSerializer.java index 58be823de..fe1eab959 100644 --- a/lang-java/src/main/java/org/eclipse/steady/java/sign/gson/ASTSignatureChangeSerializer.java +++ b/lang-java/src/main/java/org/eclipse/steady/java/sign/gson/ASTSignatureChangeSerializer.java @@ -67,6 +67,7 @@ private void writeSourceCodeEntityElement( jgen.writeObjectFieldStart(_property_name); jgen.writeStringField("UniqueName", _entity.getUniqueName().toString()); jgen.writeStringField("EntityType", _entity.getType().toString()); + jgen.writeStringField("Modifiers", Integer.toString(_entity.getModifiers())); jgen.writeObjectFieldStart("SourceCodeRange"); jgen.writeStringField("Start", Integer.toString(_entity.getSourceRange().getStart())); diff --git a/rest-backend/pom.xml b/rest-backend/pom.xml index b0a72cd26..7fddeb6bc 100644 --- a/rest-backend/pom.xml +++ b/rest-backend/pom.xml @@ -26,8 +26,8 @@ org.springframework.boot spring-boot-starter-parent - 1.5.22.RELEASE - + 2.5.1 + org.eclipse.steady @@ -111,19 +111,9 @@ ${skip.install.deploy} ${skip.install.deploy} - - 1.9.4 - 5.4.25.Final - 2.9.10.20210106 - 1.2.3 - 2.13.3 - 1.26 - 4.3.29.RELEASE - 8.5.63 - org.eclipse.steady shared @@ -168,31 +158,14 @@ json-path 2.4.0 - - - - io.swagger - swagger-annotations - 1.5.22 - - - io.swagger - swagger-core - 1.5.22 - - - - - io.springfox - springfox-swagger2 - 2.9.2 - + + - io.springfox - springfox-swagger-ui - 2.9.2 - - + org.springdoc + springdoc-openapi-ui + 1.2.32 + + com.sun.mail javax.mail @@ -204,6 +177,12 @@ javax.activation-api 1.2.0 + + + com.google.guava + guava + 28.2-jre + @@ -218,6 +197,25 @@ spring-boot-starter-test test + + org.springframework + spring-mock + 2.0.8 + test + + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + @@ -237,9 +235,9 @@ org.flywaydb flyway-core - 5.0.7 + 6.5.7 - + javax.interceptor diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/model/Dependency.java b/rest-backend/src/main/java/org/eclipse/steady/backend/model/Dependency.java old mode 100644 new mode 100755 index 8adfa04f5..d95b7ebc1 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/model/Dependency.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/model/Dependency.java @@ -119,7 +119,7 @@ public class Dependency implements Serializable { @Column(columnDefinition = "text") private String path; - @Column(columnDefinition = "text") + @Column(length = 1024) private String relativePath; @ManyToMany( @@ -134,22 +134,23 @@ public class Dependency implements Serializable { private Set touchPoints; /** - * Only set when single dependencies are returned by {@link ApplicationController#getDependency(String, String, String, String)}. - * TODO: Maybe check if they can always bet set (depending on performance and memory). + * Only set when single dependencies are returned by {@link + * ApplicationController#getDependency(String, String, String, String)}. TODO: Maybe check if they + * can always bet set (depending on performance and memory). */ @Transient private Collection traces; /** - * Contains collections of reachable dependency constructs per {@link ConstructType}. - * It MUST be a subset of what can be obtained from the library via {@link Library#countConstructTypes()}. + * Contains collections of reachable dependency constructs per {@link ConstructType}. It MUST be a + * subset of what can be obtained from the library via {@link Library#countConstructTypes()}. */ @Transient private ConstructIdFilter reachableFilter = null; /** - * Contains collections of traced dependency constructs per {@link ConstructType}. - * It MUST be a subset of what can be obtained from the library via {@link Library#countConstructTypes()}. - * Depending on the quality of the reachability analysis, it SHOULD be a subset of what can be obtained - * via {@link Dependency#countReachableConstructTypes()}. + * Contains collections of traced dependency constructs per {@link ConstructType}. It MUST be a + * subset of what can be obtained from the library via {@link Library#countConstructTypes()}. + * Depending on the quality of the reachability analysis, it SHOULD be a subset of what can be + * obtained via {@link Dependency#countReachableConstructTypes()}. */ @Transient private ConstructIdFilter tracedFilter = null; diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepository.java index fd41c6c12..c52c6e04b 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepository.java @@ -56,14 +56,6 @@ public interface ApplicationRepository /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - /** - *

findById.

- * - * @param id a {@link java.lang.Long} object. - * @return a {@link java.util.List} object. - */ - List findById(@Param("id") Long id); - /** *

findByGA.

* diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepositoryImpl.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepositoryImpl.java index 952e38fd0..349707786 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepositoryImpl.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/ApplicationRepositoryImpl.java @@ -541,12 +541,11 @@ public TreeSet findAppVulnerableDependencies( for (Object[] e : bundledDigests) { Dependency depWithBundledLibId = - DependencyRepository.FILTER.findOne( - this.depRepository.findById(((BigInteger) e[0]).longValue())); + this.depRepository.findById(((BigInteger) e[0]).longValue()).orElse(null); Library bundledDigest = - LibraryRepository.FILTER.findOne( - this.libRepository.findById(((BigInteger) e[1]).longValue())); + this.libRepository.findById(((BigInteger) e[1]).longValue()).orElse(null); + List vulns_cc = this.bugRepository.findByLibrary(bundledDigest); for (Bug b : vulns_cc) { @@ -570,12 +569,10 @@ public TreeSet findAppVulnerableDependencies( for (Object[] e : bundledLibIds) { Dependency depWithBundledLibId = - DependencyRepository.FILTER.findOne( - this.depRepository.findById(((BigInteger) e[0]).longValue())); + this.depRepository.findById(((BigInteger) e[0]).longValue()).orElse(null); LibraryId bundledLibId = - LibraryIdRepository.FILTER.findOne( - this.libIdRepository.findById(((BigInteger) e[1]).longValue())); + this.libIdRepository.findById(((BigInteger) e[1]).longValue()).orElse(null); List vulns_av_true = this.bugRepository.findByLibId(bundledLibId, true); diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/BugRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/BugRepository.java index d5e9e1888..653137177 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/BugRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/BugRepository.java @@ -43,15 +43,6 @@ public interface BugRepository extends CrudRepository, BugRepositoryC /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - /** - *

findById.

- * - * @param id a {@link java.lang.Long} object. - * @return a {@link java.util.List} object. - */ - @Query("SELECT b FROM Bug b JOIN FETCH b.constructChanges WHERE b.id=:id") - List findById(@Param("id") Long id); - /** *

findByBugId.

* diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/DependencyRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/DependencyRepository.java index 18e5046c0..679ef1e64 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/DependencyRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/DependencyRepository.java @@ -42,15 +42,6 @@ public interface DependencyRepository /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - /** - *

findById.

- * - * @param id a {@link java.lang.Long} object. - * @return a {@link java.util.List} object. - */ - @Query("SELECT dep FROM Dependency dep JOIN FETCH dep.lib l WHERE dep.id = :id") - List findById(@Param("id") Long id); - /** *

findByDigest.

* diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/GoalExecutionRepositoryImpl.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/GoalExecutionRepositoryImpl.java index 1d77b6b39..c67d8afae 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/GoalExecutionRepositoryImpl.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/GoalExecutionRepositoryImpl.java @@ -96,7 +96,7 @@ public GoalExecution findLatestGoalExecution(Application _app, GoalType _type) { Long id = null; if (_type != null) id = this.gexeRepository.findLatestForApp(_app.getId(), _type.toString()); else id = this.gexeRepository.findLatestForApp(_app.getId()); - if (id != null) return this.gexeRepository.findOne(id); + if (id != null) return this.gexeRepository.findById(id).orElse(null); else return null; } diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryIdRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryIdRepository.java index 136834d8f..55eb3d727 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryIdRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryIdRepository.java @@ -38,9 +38,6 @@ public interface LibraryIdRepository extends CrudRepository { /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - @Query("SELECT l FROM LibraryId l WHERE l.id=:id") - List findById(@Param("id") Long id); - /** *

findBySecondaryKey.

* diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryRepository.java index 6673d5e99..e1a78d6c6 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/LibraryRepository.java @@ -44,15 +44,6 @@ public interface LibraryRepository extends CrudRepository, Librar /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - /** - *

findById.

- * - * @param id a {@link java.lang.Long} object. - * @return a {@link java.util.List} object. - */ - @Query("SELECT l FROM Library l LEFT OUTER JOIN FETCH l.libraryId WHERE l.id=:id") - List findById(@Param("id") Long id); - /** *

findByDigest.

* diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/SpaceRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/SpaceRepository.java index ad31b371c..cd0e4dcb6 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/SpaceRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/SpaceRepository.java @@ -38,14 +38,6 @@ public interface SpaceRepository extends CrudRepository, SpaceRepos /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - /** - *

findById.

- * - * @param id a {@link java.lang.Long} object. - * @return a {@link java.util.List} object. - */ - List findById(@Param("id") Long id); - /** * All spaces of the given {@link Tenant}. * diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/TenantRepository.java b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/TenantRepository.java index 4fbb2d896..a0c5d2fa1 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/repo/TenantRepository.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/repo/TenantRepository.java @@ -37,14 +37,6 @@ public interface TenantRepository extends CrudRepository, TenantRe /** Constant FILTER */ public static final ResultSetFilter FILTER = new ResultSetFilter(); - /** - *

findById.

- * - * @param id a {@link java.lang.Long} object. - * @return a {@link java.util.List} object. - */ - List findById(@Param("id") Long id); - /** *

findBySecondaryKey.

* diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/ApplicationController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/ApplicationController.java index b4511a041..555c65e17 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/ApplicationController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/ApplicationController.java @@ -92,7 +92,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration; +import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; import org.springframework.http.HttpHeaders; @@ -109,7 +109,9 @@ import com.fasterxml.jackson.annotation.JsonView; -import springfox.documentation.annotations.ApiIgnore; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; /** * RESTful interface for application information. @@ -117,6 +119,8 @@ @RestController @CrossOrigin(origins = "*") @RequestMapping(path = "/apps") +@OpenAPIDefinition( + security = {@SecurityRequirement(name = "tenant"), @SecurityRequirement(name = "space")}) public class ApplicationController { private static Logger log = LoggerFactory.getLogger(ApplicationController.class); @@ -218,7 +222,8 @@ public ResponseEntity createApplication( @RequestBody Application application, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -268,14 +273,18 @@ public ResponseEntity createApplication( * @param mode a {@link java.lang.String} object. * @param space a {@link java.lang.String} object. */ - @RequestMapping(value = "/{mvnGroup:.+}/{artifact:.+}", method = RequestMethod.DELETE) + @RequestMapping( + value = "/{mvnGroup:.+}/{artifact:.+}", + method = RequestMethod.DELETE, + produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) public ResponseEntity> purgeApplicationVersions( @PathVariable String mvnGroup, @PathVariable String artifact, @RequestParam(value = "keep", required = false, defaultValue = "3") Integer keep, @RequestParam(value = "mode", required = false, defaultValue = "versions") String mode, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -432,7 +441,8 @@ public ResponseEntity updateApplication( @RequestBody Application application, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -505,7 +515,8 @@ public ResponseEntity> getApplications( @RequestParam(value = "artifact", required = false, defaultValue = "*") String a, @RequestParam(value = "version", required = false, defaultValue = "*") String v, @RequestParam(value = "asOf", required = false, defaultValue = "0") String asOfTimestamp, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -740,7 +751,8 @@ public ResponseEntity cleanApplication( @RequestParam(value = "clean", required = true) Boolean clean, @RequestParam(value = "cleanGoalHistory", required = false, defaultValue = "false") Boolean cleanGoalHistory, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -790,7 +802,8 @@ public ResponseEntity cleanApplication( */ @RequestMapping( value = "/{mvnGroup:.+}/{artifact:.+}/{version:.+}/search", - method = RequestMethod.GET) + method = RequestMethod.GET, + produces = {"application/json;charset=UTF-8"}) @JsonView(Views.Default.class) public ResponseEntity> searchConstructsInAppDependencies( @PathVariable String mvnGroup, @@ -801,7 +814,8 @@ public ResponseEntity> searchConstructsInAppDependenc ConstructType[] constructTypes, @RequestParam(value = "wildcardSearch", required = false, defaultValue = "true") boolean wildcardSearch, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -880,7 +894,8 @@ public ResponseEntity isApplicationExisting( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -921,7 +936,8 @@ public ResponseEntity getApplication( @PathVariable String version, @RequestParam(value = "inclTraces", required = false, defaultValue = "true") Boolean inclTraces, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -968,7 +984,8 @@ public ResponseEntity> getApplicationConstructIds( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1015,7 +1032,8 @@ public ResponseEntity createGoalExecution( @RequestBody GoalExecution goalExecution, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1081,7 +1099,8 @@ public ResponseEntity updateGoalExecution( @RequestBody GoalExecution goalExecution, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1131,7 +1150,8 @@ public ResponseEntity isGoalExecutionExisting( @PathVariable String artifact, @PathVariable String version, @PathVariable String executionId, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1179,7 +1199,8 @@ public ResponseEntity getGoalExecution( @PathVariable String artifact, @PathVariable String version, @PathVariable Long id, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1199,7 +1220,7 @@ public ResponseEntity getGoalExecution( } // Ensure that goal execution exists - final GoalExecution gexe = this.gexeRepository.findOne(id); + final GoalExecution gexe = this.gexeRepository.findById(id).orElse(null); if (gexe == null) return new ResponseEntity(HttpStatus.NOT_FOUND); return new ResponseEntity(gexe, HttpStatus.OK); @@ -1225,7 +1246,8 @@ public ResponseEntity getLatestGoalExecution( @PathVariable String artifact, @PathVariable String version, @RequestParam(value = "type", required = false, defaultValue = "") String type, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1277,7 +1299,8 @@ public ResponseEntity> getGoalExecutions( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1318,7 +1341,8 @@ public ResponseEntity> deleteGoalExecutions( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1371,7 +1395,8 @@ public ResponseEntity> getApplicationBugs( @PathVariable String version, @RequestParam(value = "historical", required = false, defaultValue = "false") Boolean historical, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1422,7 +1447,8 @@ public ResponseEntity> findDependencyIntersections( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1477,7 +1503,8 @@ public ResponseEntity> getDependencies( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1534,7 +1561,8 @@ public ResponseEntity getDependency( @PathVariable String artifact, @PathVariable String version, @PathVariable String digest, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1589,7 +1617,8 @@ public ResponseEntity getApplicationMetrics( @PathVariable String version, @RequestParam(value = "excludedScopes", required = false, defaultValue = "") Scope[] excludedScopes, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1721,7 +1750,8 @@ public ResponseEntity getUpda @PathVariable String version, @PathVariable String digest, @RequestBody LibraryId otherVersion, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -1941,7 +1971,8 @@ public ResponseEntity getUpda @PathVariable String version, @PathVariable String digest, @RequestBody LibraryId otherVersion, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2059,7 +2090,8 @@ public ResponseEntity> getAppVulnerableDependencie // "vulas.report.exceptionExcludeBugs" @RequestParam(value = "lastChange", required = false, defaultValue = "") String lastChange, // a timestamp identifier which is used to cache the response or not - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2135,8 +2167,7 @@ public ResponseEntity> getVulnerableDependencies( try { VulnerableDependency vd = new VulnerableDependency( - DependencyRepository.FILTER.findOne( - this.depRepository.findById(entry.getKey().longValue())), + this.depRepository.findById(entry.getKey().longValue()).orElse(null), BugRepository.FILTER.findOne(this.bugRepository.findByBugId(entry.getValue()))); vd_list.add(vd); } catch (EntityNotFoundException e) { @@ -2205,7 +2236,8 @@ public ResponseEntity getVulnerableDependencyBugDetails( String bundledVersion, @RequestParam(value = "bundledLibrary", required = false, defaultValue = "") String bundledLibrary, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2266,7 +2298,8 @@ public ResponseEntity> createTraces( @RequestBody Trace[] traces, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2319,7 +2352,8 @@ public ResponseEntity> getTraces( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2361,7 +2395,8 @@ public ResponseEntity> getReachableContructIds( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2409,7 +2444,8 @@ public ResponseEntity> createPaths( @RequestBody Path[] paths, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2462,7 +2498,8 @@ public ResponseEntity> getPaths( @PathVariable String mvnGroup, @PathVariable String artifact, @PathVariable String version, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2508,7 +2545,8 @@ public ResponseEntity> getVulndepPaths( @PathVariable String version, @PathVariable String digest, @PathVariable String bugId, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2579,7 +2617,8 @@ public ResponseEntity> getVulndepConstructPaths( @PathVariable String digest, @PathVariable String bugId, @PathVariable String qname, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2677,7 +2716,8 @@ public ResponseEntity> createReachableConstructIds( @PathVariable String version, @PathVariable String digest, @RequestBody ConstructId[] constructIds, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; @@ -2754,7 +2794,8 @@ public ResponseEntity> createTouchPoints( @RequestBody TouchPoint[] touchPoints, @RequestParam(value = "skipResponseBody", required = false, defaultValue = "false") Boolean skipResponseBody, - @ApiIgnore @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_SPACE_HEADER, required = false) String space) { Space s = null; diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/BugController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/BugController.java index c8d244cd8..be6a63f9b 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/BugController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/BugController.java @@ -39,7 +39,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; -import org.springframework.hateoas.Resource; +// hateos.Resource was renamed into EntityModel (see +// https://docs.spring.io/spring-hateoas/docs/current/reference/html/#migrate-to-1.0) +import org.springframework.hateoas.EntityModel; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; @@ -287,20 +289,23 @@ public ResponseEntity updateBug(@PathVariable String bugid, @RequestBody Bu * @return 404 {@link HttpStatus#NOT_FOUND} if bug with given bug ID does not exist, 200 {@link HttpStatus#OK} if the bug was successfully deleted * @param bugid a {@link java.lang.String} object. */ - @RequestMapping(value = "/{bugid}", method = RequestMethod.DELETE) + @RequestMapping( + value = "/{bugid}", + method = RequestMethod.DELETE, + produces = {"application/json;charset=UTF-8"}) @CacheEvict(value = "bug") - public ResponseEntity> deleteBug(@PathVariable String bugid) { + public ResponseEntity> deleteBug(@PathVariable String bugid) { try { final Bug b = BugRepository.FILTER.findOne(this.bugRepository.findByBugId(bugid)); // Ensure that no affected libs for bug exist final List aff_libs = this.afflibRepository.findByBug(b); if (aff_libs != null && aff_libs.size() > 0) - return new ResponseEntity>(HttpStatus.UNPROCESSABLE_ENTITY); + return new ResponseEntity>(HttpStatus.UNPROCESSABLE_ENTITY); this.bugRepository.delete(b); - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.OK); } catch (EntityNotFoundException enfe) { - return new ResponseEntity>(HttpStatus.NOT_FOUND); + return new ResponseEntity>(HttpStatus.NOT_FOUND); } } diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/CoverageController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/CoverageController.java index bb4606354..40978a1eb 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/CoverageController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/CoverageController.java @@ -35,8 +35,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration; -import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; @@ -44,7 +42,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.DispatcherServlet; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -72,18 +69,6 @@ public class CoverageController { private final BugRepository bugRepository; - /** - *

dispatcherServlet.

- * - * @return a {@link org.springframework.web.servlet.DispatcherServlet} object. - */ - @Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME) - public DispatcherServlet dispatcherServlet() { - DispatcherServlet dispatcherServlet = new DispatcherServlet(); - dispatcherServlet.setDispatchOptionsRequest(true); - return dispatcherServlet; - } - @Autowired CoverageController(BugRepository bugRepository) { this.bugRepository = bugRepository; diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/HubIntegrationController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/HubIntegrationController.java index 24ae029ba..812450409 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/HubIntegrationController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/HubIntegrationController.java @@ -51,8 +51,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration; -import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; @@ -62,7 +60,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.DispatcherServlet; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -97,18 +94,6 @@ public class HubIntegrationController { private final TenantRepository tenantRepository; - /** - *

dispatcherServlet.

- * - * @return a {@link org.springframework.web.servlet.DispatcherServlet} object. - */ - @Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME) - public DispatcherServlet dispatcherServlet() { - DispatcherServlet dispatcherServlet = new DispatcherServlet(); - dispatcherServlet.setDispatchOptionsRequest(true); - return dispatcherServlet; - } - @Autowired HubIntegrationController( ApplicationRepository appRepository, diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryController.java index 233750f0a..ef5c9c7d9 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryController.java @@ -52,7 +52,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.hateoas.Resource; +// hateos.Resource was renamed into EntityModel (see +// https://docs.spring.io/spring-hateoas/docs/current/reference/html/#migrate-to-1.0) +import org.springframework.hateoas.EntityModel; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -146,7 +148,8 @@ public Iterable getLibraries( @RequestMapping( value = "", method = RequestMethod.POST, - consumes = {"application/json;charset=UTF-8"}) + consumes = {"application/json;charset=UTF-8"}, + produces = {"application/json;charset=UTF-8"}) @JsonView(Views.LibDetails.class) public ResponseEntity createLibrary( @RequestBody Library library, @@ -225,7 +228,8 @@ public ResponseEntity> getLibraryApplications(@PathVariable St @RequestMapping( value = "/{digest}", method = RequestMethod.PUT, - consumes = {"application/json;charset=UTF-8"}) + consumes = {"application/json;charset=UTF-8"}, + produces = {"application/json;charset=UTF-8"}) @JsonView(Views.LibDetails.class) public ResponseEntity updateLibrary( @PathVariable String digest, @@ -259,7 +263,8 @@ public ResponseEntity updateLibrary( @RequestMapping( value = "/{digest}/updateMetadata", method = RequestMethod.PUT, - consumes = {"application/json;charset=UTF-8"}) + consumes = {"application/json;charset=UTF-8"}, + produces = {"application/json;charset=UTF-8"}) @JsonView(Views.LibDetails.class) public ResponseEntity updateLibraryMetaData( @PathVariable String digest, @@ -305,13 +310,13 @@ public ResponseEntity isLibraryExisting(@PathVariable String digest) { value = "/{digest}", method = RequestMethod.DELETE, produces = {"application/json;charset=UTF-8"}) - public ResponseEntity> deleteLibrary(@PathVariable String digest) { + public ResponseEntity> deleteLibrary(@PathVariable String digest) { try { final Library lib = LibraryRepository.FILTER.findOne(this.libRepository.findByDigest(digest)); this.libRepository.delete(lib); - return new ResponseEntity>(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.OK); } catch (EntityNotFoundException enfe) { - return new ResponseEntity>(HttpStatus.NOT_FOUND); + return new ResponseEntity>(HttpStatus.NOT_FOUND); } } diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryIdController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryIdController.java index d6cddd540..f28a73c52 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryIdController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/LibraryIdController.java @@ -230,14 +230,11 @@ public ResponseEntity> getA for (Object[] e : libids_w_rebundles) { // check whether the libId rebundles a vulnerable library. If so, add it to vuln_libids - LibraryId lid = - LibraryIdRepository.FILTER.findOne( - libIdRepository.findById(((BigInteger) e[0]).longValue())); + LibraryId lid = libIdRepository.findById(((BigInteger) e[0]).longValue()).orElse(null); if (!vuln_libids.contains(lid.toSharedType())) { LibraryId lid_bundled = - LibraryIdRepository.FILTER.findOne( - libIdRepository.findById(((BigInteger) e[1]).longValue())); + libIdRepository.findById(((BigInteger) e[1]).longValue()).orElse(null); for (AffectedLibrary afflib : lid_bundled.getAffLibraries()) { Boolean affected = diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/MainController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/MainController.java index cd8b68d71..111b6f5d5 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/MainController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/MainController.java @@ -18,22 +18,13 @@ */ package org.eclipse.steady.backend.rest; -import static com.google.common.base.Predicates.or; -import static com.google.common.collect.Lists.newArrayList; -import static springfox.documentation.builders.PathSelectors.regex; +import org.springdoc.core.GroupedOpenApi; -import java.util.ArrayList; - -import org.eclipse.steady.backend.repo.BugRepositoryImpl; -import org.eclipse.steady.backend.util.ReferenceUpdater; -import org.eclipse.steady.shared.util.Constants; -import org.eclipse.steady.shared.util.VulasConfiguration; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -41,23 +32,16 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import com.fasterxml.classmate.TypeResolver; -import com.google.common.base.Predicate; +import org.eclipse.steady.backend.repo.BugRepositoryImpl; +import org.eclipse.steady.backend.util.ReferenceUpdater; +import org.eclipse.steady.shared.util.Constants; +import org.eclipse.steady.shared.util.VulasConfiguration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.AuthorizationScopeBuilder; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ApiKey; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.BasicAuth; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.service.SecurityScheme; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger.web.ApiKeyVehicle; -import springfox.documentation.swagger.web.SecurityConfiguration; -import springfox.documentation.swagger2.annotations.EnableSwagger2; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.security.SecurityScheme.In; /** *

MainController class.

@@ -68,8 +52,6 @@ "org.eclipse.steady.backend.component,org.eclipse.steady.backend.rest,org.eclipse.steady.backend.util" }) @EnableAutoConfiguration -// @EnableWebMvc -// @SpringBootApplication @EnableCaching @EntityScan({ "org.eclipse.steady.backend.model" @@ -77,7 +59,6 @@ @EnableJpaRepositories({ "org.eclipse.steady.backend.repo" }) // So that repos in the repo package are discovered -@EnableSwagger2 public class MainController extends SpringBootServletInitializer { /** @@ -109,171 +90,64 @@ ReferenceUpdater refUpdater() { * Returns the API info for Swagger. * @return */ - private final ApiInfo getApiInfo() { - return new ApiInfoBuilder() - .title("Eclipse Steady") - .description("RESTful API for managing applications and vulnerabilities") - .version(VulasConfiguration.getGlobal().getConfiguration().getString("shared.version")) - .build(); - } - - /** - * Paths related to vulnerabilities. - * @return - */ - @SuppressWarnings("unchecked") - private Predicate bugPaths() { - return or(regex("/bugs.*"), regex("/coverage.*"), regex("/cves.*")); - } - - /** - * Paths that require tenant selection. - * @return - */ - @SuppressWarnings("unchecked") - private Predicate userPaths() { - return or( - regex("/apps.*"), - regex("/hubIntegration.*"), - regex("/libs.*"), - regex("/libids.*"), - regex("/spaces.*")); - } - - /** - * Paths related to configuration and tenant management. - * @return - */ - private Predicate configPaths() { - return or(regex("/configuration.*"), regex("/tenants.*")); + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components( + new Components() + .addSecuritySchemes( + "tenant", + new SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .in(In.HEADER) + .name(Constants.HTTP_TENANT_HEADER)) + .addSecuritySchemes( + "space", + new SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .in(In.HEADER) + .name(Constants.HTTP_SPACE_HEADER))) + .info( + new Info() + .title("Vulas REST API") + .description("This is the REST API of Vulas") + .version( + VulasConfiguration.getGlobal().getConfiguration().getString("shared.version"))); } /** *

bugApi.

* - * @return a {@link springfox.documentation.spring.web.plugins.Docket} object. + * @return a {@link org.springdoc.core.GroupedOpenApi} object. */ @Bean - public Docket bugApi() { - return new Docket(DocumentationType.SWAGGER_2) - .groupName("bug-api") - .apiInfo(this.getApiInfo()) - .select() - // .apis(RequestHandlerSelectors.any()) - .paths(this.bugPaths()) - .build() - // .pathMapping("/") - ; + public GroupedOpenApi bugApi() { + String paths[] = {"/bugs/**", "/coverage/**", "/cves/**"}; + return GroupedOpenApi.builder().setGroup("bug-api").pathsToMatch(paths).build(); } /** *

userApi.

* - * @return a {@link springfox.documentation.spring.web.plugins.Docket} object. + * @return a {@link org.springdoc.core.GroupedOpenApi} object. */ @Bean - public Docket userApi() { - AuthorizationScope[] authScopes = new AuthorizationScope[1]; - - authScopes[0] = - new AuthorizationScopeBuilder().scope("read").description("read access").build(); - - SecurityReference securityReference1 = - SecurityReference.builder().reference("tenant").scopes(authScopes).build(); - - SecurityReference securityReference2 = - SecurityReference.builder().reference("space").scopes(authScopes).build(); - - ArrayList securityContexts = - newArrayList( - SecurityContext.builder() - .securityReferences(newArrayList(securityReference1, securityReference2)) - .build()); - - return new Docket(DocumentationType.SWAGGER_2) - .groupName("user-api") - .apiInfo(this.getApiInfo()) - .select() - // .apis(RequestHandlerSelectors.any()) - .paths(this.userPaths()) - .build() - // .pathMapping("/") - .securitySchemes(newArrayList(this.tenantKey(), this.spaceKey())) - .securityContexts(securityContexts); + public GroupedOpenApi userApi() { + String paths[] = {"/apps/**", "/hubIntegration/**", "/libs/**", "/libids/**", "/spaces/**"}; + return GroupedOpenApi.builder().setGroup("user-api").pathsToMatch(paths).build(); } /** *

adminApi.

* - * @return a {@link springfox.documentation.spring.web.plugins.Docket} object. + * @return a {@link org.springdoc.core.GroupedOpenApi} object. */ @Bean - public Docket adminApi() { - AuthorizationScope[] authScopes = new AuthorizationScope[1]; - - authScopes[0] = - new AuthorizationScopeBuilder().scope("read").description("read access").build(); - - SecurityReference securityReference = - SecurityReference.builder().reference("test").scopes(authScopes).build(); - - ArrayList securityContexts = - newArrayList( - SecurityContext.builder().securityReferences(newArrayList(securityReference)).build()); - - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(this.getApiInfo()) - .groupName("config-api") - .select() - // .apis(RequestHandlerSelectors.any()) - .paths(this.configPaths()) - .build() - // .pathMapping("/") - .securitySchemes(newArrayList(new BasicAuth("test"))) - .securityContexts(securityContexts); - - /*.directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class) - .alternateTypeRules(newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) - .useDefaultResponseMessages(false) - .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build())) - .securitySchemes(newArrayList(this.tenantKey())).securityContexts(newArrayList(securityContext()));*/ + public GroupedOpenApi adminApi() { + String paths[] = {"/configuration/**", "/tenants/**"}; + return GroupedOpenApi.builder().setGroup("admin-api").pathsToMatch(paths).build(); } - @Autowired private TypeResolver typeResolver; - - @Bean - SecurityScheme tenantKey() { - return new ApiKey("tenant", Constants.HTTP_TENANT_HEADER, "header"); - } - - @Bean - SecurityScheme spaceKey() { - return new ApiKey("space", Constants.HTTP_SPACE_HEADER, "header"); - } - - /** - *

securityInfo.

- * - * @return a {@link springfox.documentation.swagger.web.SecurityConfiguration} object. - */ - @Bean - public SecurityConfiguration securityInfo() { - return new SecurityConfiguration( - "abc", - "123", - "pets", - "petstore", - Constants.HTTP_TENANT_HEADER, - ApiKeyVehicle.HEADER, - "", - ","); - } - - // @Bean - // UiConfiguration uiConfig() { - // return new UiConfiguration("validatorUrl"); - // } - /** * Can be used to do some initialization at application startup, but does not do anything right now. * diff --git a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/SpaceController.java b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/SpaceController.java index 5909254d4..45053a7d8 100644 --- a/rest-backend/src/main/java/org/eclipse/steady/backend/rest/SpaceController.java +++ b/rest-backend/src/main/java/org/eclipse/steady/backend/rest/SpaceController.java @@ -63,7 +63,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import springfox.documentation.annotations.ApiIgnore; +import io.swagger.v3.oas.annotations.Parameter; /** *

SpaceController class.

@@ -117,7 +117,8 @@ public class SpaceController { method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) public ResponseEntity> getAllSpaces( - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { // Check whether tenant exists or retrieve default @@ -150,7 +151,8 @@ public ResponseEntity> getAllSpaces( method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) public ResponseEntity getDefaultSpace( - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { // Check whether tenant exists or retrieve default @@ -193,7 +195,8 @@ public ResponseEntity> searchSpaces( @RequestParam(value = "caseSensitivity", required = false, defaultValue = "CASE_SENSITIVE") CaseSensitivity caseSensitivity, @RequestParam(value = "value", required = true) String[] value, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { // Check whether tenant exists or retrieve default @@ -233,7 +236,8 @@ public ResponseEntity> searchSpaces( @RequestMapping(value = "/{token:.+}", method = RequestMethod.OPTIONS) public ResponseEntity isSpaceExisting( @PathVariable String token, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { // Check whether tenant exists or retrieve default Tenant t = null; @@ -259,10 +263,14 @@ public ResponseEntity isSpaceExisting( * @return 404 {@link HttpStatus#NOT_FOUND} if space with given token does not exist, 200 {@link HttpStatus#OK} if the space is found * @param tenant a {@link java.lang.String} object. */ - @RequestMapping(value = "/{token:.+}", method = RequestMethod.GET) + @RequestMapping( + value = "/{token:.+}", + method = RequestMethod.GET, + produces = {"application/json;charset=UTF-8"}) public ResponseEntity getSpace( @PathVariable String token, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { // Check whether tenant exists or retrieve default Tenant t = null; @@ -296,7 +304,8 @@ public ResponseEntity getSpace( produces = {"application/json;charset=UTF-8"}) public ResponseEntity createSpace( @RequestBody Space space, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { final StopWatch sw = new StopWatch( @@ -370,7 +379,8 @@ public ResponseEntity createSpace( public ResponseEntity modifySpace( @PathVariable String token, @RequestBody Space new_space, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { try { // Check arguments @@ -460,7 +470,8 @@ public ResponseEntity modifySpace( public ResponseEntity cleanSpace( @PathVariable String token, @RequestParam(value = "clean", required = true) Boolean clean, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { try { @@ -553,7 +564,8 @@ public ResponseEntity cleanSpace( @RequestMapping(value = "/{token:.+}", method = RequestMethod.DELETE) public ResponseEntity deleteSpace( @PathVariable String token, - @ApiIgnore @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) + @Parameter(hidden = true) + @RequestHeader(value = Constants.HTTP_TENANT_HEADER, required = false) String tenant) { try { diff --git a/rest-backend/src/main/resources/application-docker.properties b/rest-backend/src/main/resources/application-docker.properties index 508756c20..dcf7a85c7 100755 --- a/rest-backend/src/main/resources/application-docker.properties +++ b/rest-backend/src/main/resources/application-docker.properties @@ -33,6 +33,6 @@ spring.datasource.username= #Default: spring.datasource.password= -flyway.locations=classpath:db/migration,filesystem:/flyway-callbacks +spring.flyway.locations=classpath:db/migration,filesystem:/flyway-callbacks #mounted on opt/vulas/data/db-dump/ diff --git a/rest-backend/src/main/resources/application-test.properties b/rest-backend/src/main/resources/application-test.properties index b4df17de3..0acac8bb5 100755 --- a/rest-backend/src/main/resources/application-test.properties +++ b/rest-backend/src/main/resources/application-test.properties @@ -21,7 +21,7 @@ spring.profiles=test server.port = 8091 -flyway.enabled=false +spring.flyway.enabled=false spring.jpa.hibernate.ddl-auto=create-drop #validate | update | create | create-drop diff --git a/rest-backend/src/main/resources/application.properties b/rest-backend/src/main/resources/application.properties index b9bb3f060..6a52db2bc 100644 --- a/rest-backend/src/main/resources/application.properties +++ b/rest-backend/src/main/resources/application.properties @@ -52,12 +52,12 @@ spring.jpa.hibernate.ddl-auto=validate #validate | update | create | create-drop server.port = 8091 -server.contextPath=/backend +server.servlet.contextPath=/backend spring.profiles.active=docker #flyway.placeholderPrefix=${ -flyway.placeholder-replacement= false -flyway.skipDefaultCallbacks=true +spring.flyway.placeholder-replacement= false +spring.flyway.skipDefaultCallbacks=true # Settings for Actuator trace # @@ -65,7 +65,20 @@ flyway.skipDefaultCallbacks=true # https://github.com/spring-projects/spring-boot/blob/v1.5.2.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceProperties.java # https://www.dontpanicblog.co.uk/2017/04/14/spring-boot-actuator-trace/ #spring.jackson.date-format=yyyy-MM-dd HH:mm:ss -management.trace.include=REQUEST_HEADERS, RESPONSE_HEADERS, ERRORS, QUERY_STRING +# in spring 1.5.x config was management.trace.include=REQUEST_HEADERS, RESPONSE_HEADERS, ERRORS, QUERY_STRING +# spring 2.x enums valid values: AUTHORIZATION_HEADER,COOKIE_HEADERS,PRINCIPAL,REMOTE_ADDRESS,REQUEST_HEADERS,RESPONSE_HEADERS,SESSION_ID,TIME_TAKEN +management.trace.http.include=REQUEST_HEADERS,RESPONSE_HEADERS #Flyway changed its default for flyway.table in version 5.0.0 to flyway_schema_history and you are still relying on the old default (schema_version). Set flyway.table=schema_version in your configuration to fix this. This fallback mechanism will be removed in Flyway 6.0.0. -flyway.table=schema_version +spring.flyway.table=schema_version + +#since spring 2.x we use Hikari jdbc as springboot changed its default (previously tomcat jdbc) +#spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource +# setting max size of connection pool to the default previously used by tomcat JDBC +spring.datasource.hikari.maximum-pool-size=100 +#minimum number of idle connections that HikariCP tries to maintain in the pool. Default: same as maximumPoolSize (see https://github.com/brettwooldridge/HikariCP#gear-configuration-knobs-baby) +#spring.datasource.hikari.minimum-idle + +# In Spring 2 the following propert changed the default from false to true (https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#id-generator). +# When "true" the performances of our Junit tests gets considerably bad. Moreover it is reported to create incompatibilities with existing keys that needs to be addressed with migrations (to be investigated) +spring.jpa.hibernate.use-new-id-generator-mappings=false \ No newline at end of file diff --git a/rest-backend/src/main/resources/db/migration/V20200219.1130__dropDepIndexes.sql b/rest-backend/src/main/resources/db/migration/V20200219.1130__dropDepIndexes.sql index 235691fe8..2785928c8 100644 --- a/rest-backend/src/main/resources/db/migration/V20200219.1130__dropDepIndexes.sql +++ b/rest-backend/src/main/resources/db/migration/V20200219.1130__dropDepIndexes.sql @@ -1,4 +1,5 @@ DROP INDEX if exists public.dep_app_lib_index; DROP INDEX if exists public.dep_app_lib_parent_index; DROP INDEX if exists public.dep_app_lib_relpath_index; -alter table app_dependency add constraint UKnueog86fts45j2wcql6idbqwn unique (lib, app, parent, relative_path); \ No newline at end of file +ALTER TABLE app_dependency ALTER COLUMN relative_path TYPE varchar(1024); +ALTER TABLE app_dependency ADD CONSTRAINT UKnueog86fts45j2wcql6idbqwn UNIQUE (lib, app, parent, relative_path); \ No newline at end of file diff --git a/rest-backend/src/test/java/org/eclipse/steady/backend/rest/ApplicationControllerTest.java b/rest-backend/src/test/java/org/eclipse/steady/backend/rest/ApplicationControllerTest.java old mode 100644 new mode 100755 index e9101674a..a57d53618 --- a/rest-backend/src/test/java/org/eclipse/steady/backend/rest/ApplicationControllerTest.java +++ b/rest-backend/src/test/java/org/eclipse/steady/backend/rest/ApplicationControllerTest.java @@ -224,6 +224,7 @@ public void reset() throws Exception { /** * Rest-read non-existing app. + * * @throws Exception */ @Test @@ -233,6 +234,7 @@ public void testGetNotFound() throws Exception { /** * Repo-save and rest-get. + * * @throws Exception */ @Test @@ -258,6 +260,7 @@ public void testGetApp() throws Exception { /** * Repo-save and JSON export. + * * @throws Exception */ @Test @@ -312,6 +315,7 @@ public void testExportApps() throws Exception { /** * Rest-post and rest-get. + * * @throws Exception */ @Test @@ -385,6 +389,7 @@ public void testPost() throws Exception { /** * Duplicate rest-post. + * * @throws Exception */ @Test @@ -548,8 +553,8 @@ public void readAllApplications() throws Exception { // Read all apps for a non-existing token mockMvc .perform(get("/apps").header(Constants.HTTP_SPACE_HEADER, "does-not-exist")) - .andExpect(status().isNotFound()) - .andExpect(content().contentType(contentTypeJson)); + .andExpect(status().isNotFound()); + // .andExpect(content().contentType(contentTypeJson)); // Read all apps for a non-existing token mockMvc @@ -570,6 +575,7 @@ public void readAllApplications() throws Exception { /** * Rest-post goal execution. + * * @param obj * @return */ @@ -633,6 +639,7 @@ public void testPostGoalExe() throws Exception { /** * Repo-save and rest-clean + * * @param obj * @return */ @@ -659,7 +666,7 @@ public void testCleanApp() throws Exception { assertEquals(1, this.appRepository.count()); // Check that there are no constructs and dependencies any more - final Application managed_app = this.appRepository.findOne(app.getId()); + final Application managed_app = this.appRepository.findById(app.getId()).orElse(null); final Boolean isEmpty = (managed_app.getConstructs() == null || managed_app.getConstructs().isEmpty()) && (managed_app.getDependencies() == null || managed_app.getDependencies().isEmpty()); @@ -668,6 +675,7 @@ public void testCleanApp() throws Exception { /** * Repo-save and rest-clean + * * @param obj * @return */ @@ -699,6 +707,7 @@ public void testCleanPurgeApp() throws Exception { /** * Repo-save and rest-clean (fails due to read-only space) + * * @param obj * @return */ @@ -922,7 +931,7 @@ public void testGetAppVulnerabilitiesBundledAffLib() throws Exception { assertTrue(this.affLibRepository.count() == 2); - this.affLibRepository.delete(managedOuterAffLib); + for (AffectedLibrary al : managedOuterAffLib) this.affLibRepository.delete(al); assertTrue(this.affLibRepository.count() == 1); @@ -1027,8 +1036,7 @@ public void testGetAppVulnerabilitiesForBundledLibs() throws Exception { for (Object[] e : bundledDigests) { Library bundledDigest = - LibraryRepository.FILTER.findOne( - this.libRepository.findById(((BigInteger) e[1]).longValue())); + this.libRepository.findById(((BigInteger) e[1]).longValue()).orElse(null); List vulns_cc = this.bugRepository.findByLibrary(bundledDigest); assertTrue(vulns_cc.size() == 1); @@ -1174,6 +1182,7 @@ public void testGetSpaceApps() throws Exception { /** * Tests application lastVulnChange update when bug construct changes are saved + * * @return */ @Test @@ -1211,7 +1220,7 @@ public void testRefreshAppsByCC() throws Exception { this.appRepository.refreshVulnChangebyChangeList(listOfConstructChanges); - managed_app = this.appRepository.findOne(managed_app.getId()); + managed_app = this.appRepository.findById(managed_app.getId()).orElse(null); System.out.println( "Modified at before update is [" + originalLastVulnChange.getTimeInMillis() @@ -1228,6 +1237,7 @@ public void testRefreshAppsByCC() throws Exception { /** * Tests application lastVulnChange update when affected Library is saved + * * @return */ @Test @@ -1273,7 +1283,7 @@ public void testRefreshAppsByAffLib() throws Exception { // create Construct change for the already existing construct this.appRepository.refreshVulnChangebyAffLib(managed_afflib); - managed_app = this.appRepository.findOne(managed_app.getId()); + managed_app = this.appRepository.findById(managed_app.getId()).orElse(null); System.out.println( "Modified at before update is [" + originalLastVulnChange.getTimeInMillis() @@ -1290,6 +1300,7 @@ public void testRefreshAppsByAffLib() throws Exception { /** * Tests application lastScan update from rest api + * * @return */ @Test @@ -1324,8 +1335,7 @@ public void testRefreshAppsByLastScan() throws Exception { .andExpect(status().isCreated()) .andExpect(content().contentType(contentTypeJson)); - Application after_update = - ApplicationRepository.FILTER.findOne(this.appRepository.findById(managed_app.getId())); + Application after_update = this.appRepository.findById(managed_app.getId()).orElse(null); Calendar lastScanAfterPost = managed_app.getLastScan(); assertTrue(originalLastScan.getTimeInMillis() < after_update.getLastScan().getTimeInMillis()); assertTrue( @@ -1359,8 +1369,7 @@ public void testRefreshAppsByLastScan() throws Exception { // .andExpect(content().contentType(contentTypeJson)) ; // // .andExpect(jsonPath("$.lastChange", is(String.class))); - after_update = - ApplicationRepository.FILTER.findOne(this.appRepository.findById(managed_app.getId())); + after_update = this.appRepository.findById(managed_app.getId()).orElse(null); assertTrue(lastScanAfterPost.getTimeInMillis() < after_update.getLastScan().getTimeInMillis()); assertTrue( after_update.getLastScan().getTimeInMillis() @@ -1411,6 +1420,7 @@ private final Application createExampleApplication() { /** * Creates a transient {@link Library}. + * * @return */ private final Library createExampleLibrary() { @@ -1543,6 +1553,7 @@ private void createDefaultTenantandSpace() { /** * Creates a transient bug. + * * @return */ private final Bug createBugWithOutCC() { diff --git a/rest-backend/src/test/java/org/eclipse/steady/backend/rest/SpaceControllerTest.java b/rest-backend/src/test/java/org/eclipse/steady/backend/rest/SpaceControllerTest.java index 3d938c4cc..bdff8f9f4 100644 --- a/rest-backend/src/test/java/org/eclipse/steady/backend/rest/SpaceControllerTest.java +++ b/rest-backend/src/test/java/org/eclipse/steady/backend/rest/SpaceControllerTest.java @@ -279,7 +279,9 @@ public void testGetSpace() throws Exception { } /** - * Check space creation and deletion. + * Check space creation and deletion. <<<<<<< HEAD ======= + * + *

>>>>>>> master * * @throws Exception */ @@ -335,7 +337,9 @@ public void testSpaceCreationAndDeletion() throws Exception { } /** - * Test modification of read-only space. + * Test modification of read-only space. <<<<<<< HEAD ======= + * + *

>>>>>>> master * * @throws Exception */ @@ -373,7 +377,9 @@ public void testReadOnlySpace() throws Exception { } /** - * Creates a workspace and searches for it. + * Creates a workspace and searches for it. <<<<<<< HEAD ======= + * + *

>>>>>>> master * * @throws Exception */ diff --git a/rest-lib-utils/pom.xml b/rest-lib-utils/pom.xml index 7c0eae7e1..54cd811d1 100644 --- a/rest-lib-utils/pom.xml +++ b/rest-lib-utils/pom.xml @@ -26,7 +26,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.22.RELEASE + 2.5.1 @@ -117,15 +117,6 @@ ${skip.install.deploy} ${skip.install.deploy} - - 1.9.4 - 5.4.18.Final - 2.9.10.20210106 - 1.2.3 - 2.13.3 - 1.26 - 4.3.29.RELEASE - 8.5.63 @@ -176,30 +167,13 @@ 2.7 - + - io.swagger - swagger-annotations - 1.5.22 - - - io.swagger - swagger-core - 1.5.22 - - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - + org.springdoc + springdoc-openapi-ui + 1.2.32 + + org.eclipse.steady @@ -227,10 +201,11 @@ 1.2.1-beta5 - + oro oro @@ -246,6 +221,11 @@ commons-logging 1.2 + + log4j + log4j + 1.2.17 + org.apache.ant ant @@ -256,6 +236,19 @@ junit test + + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + diff --git a/rest-lib-utils/src/main/java/org/eclipse/steady/cia/rest/MainController.java b/rest-lib-utils/src/main/java/org/eclipse/steady/cia/rest/MainController.java index 0b2a91b5d..5ad3ef7c4 100644 --- a/rest-lib-utils/src/main/java/org/eclipse/steady/cia/rest/MainController.java +++ b/rest-lib-utils/src/main/java/org/eclipse/steady/cia/rest/MainController.java @@ -18,54 +18,29 @@ */ package org.eclipse.steady.cia.rest; -import static com.google.common.collect.Lists.newArrayList; -import static springfox.documentation.schema.AlternateTypeRules.newRule; - -import java.time.LocalDate; import java.util.HashMap; -import java.util.List; import java.util.Map; -import org.eclipse.steady.java.sign.ASTConstructBodySignature; -import org.eclipse.steady.java.sign.ASTSignatureChange; -import org.eclipse.steady.java.sign.gson.ASTConstructBodySignatureDeserializer; -import org.eclipse.steady.java.sign.gson.ASTConstructBodySignatureSerializer; -import org.eclipse.steady.java.sign.gson.ASTSignatureChangeSerializer; -import org.eclipse.steady.python.sign.PythonConstructDigest; -import org.eclipse.steady.python.sign.PythonConstructDigestSerializer; -import org.eclipse.steady.shared.util.Constants; -import org.eclipse.steady.shared.util.VulasConfiguration; -import org.springframework.beans.factory.annotation.Autowired; +import org.springdoc.core.GroupedOpenApi; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.http.ResponseEntity; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.context.request.async.DeferredResult; -import com.fasterxml.classmate.TypeResolver; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonSerializer; - -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.builders.ResponseMessageBuilder; -import springfox.documentation.schema.ModelRef; -import springfox.documentation.schema.WildcardType; -import springfox.documentation.service.ApiKey; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger.web.ApiKeyVehicle; -import springfox.documentation.swagger.web.SecurityConfiguration; -import springfox.documentation.swagger2.annotations.EnableSwagger2; +import org.eclipse.steady.java.sign.ASTConstructBodySignature; +import org.eclipse.steady.java.sign.ASTSignatureChange; +import org.eclipse.steady.java.sign.gson.ASTConstructBodySignatureDeserializer; +import org.eclipse.steady.java.sign.gson.ASTConstructBodySignatureSerializer; +import org.eclipse.steady.java.sign.gson.ASTSignatureChangeSerializer; +import org.eclipse.steady.python.sign.PythonConstructDigest; +import org.eclipse.steady.python.sign.PythonConstructDigestSerializer; /** *

MainController class.

@@ -74,7 +49,6 @@ @Configuration @ComponentScan({"org.eclipse.steady.cia.util,org.eclipse.steady.cia.rest"}) @EnableAutoConfiguration -@EnableSwagger2 public class MainController extends SpringBootServletInitializer { /** @@ -83,79 +57,9 @@ public class MainController extends SpringBootServletInitializer { * @return a {@link springfox.documentation.spring.web.plugins.Docket} object. */ @Bean - public Docket backendApi() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build() - .pathMapping("/") - .apiInfo( - new springfox.documentation.service.ApiInfo( - "Eclipse Steady", - "RESTful API for discovering and analyzing artifacts of package repositories", - VulasConfiguration.getGlobal().getConfiguration().getString("shared.version"), - "SAP", - null, - "commercial", - null)) - .directModelSubstitute(LocalDate.class, String.class) - .genericModelSubstitutes(ResponseEntity.class) - .alternateTypeRules( - newRule( - typeResolver.resolve( - DeferredResult.class, - typeResolver.resolve(ResponseEntity.class, WildcardType.class)), - typeResolver.resolve(WildcardType.class))) - .useDefaultResponseMessages(false) - .globalResponseMessage( - RequestMethod.GET, - newArrayList( - new ResponseMessageBuilder() - .code(500) - .message("500 message") - .responseModel(new ModelRef("Error")) - .build())); - // .securitySchemes(newArrayList(apiKey())).securityContexts(newArrayList(securityContext())); - } - - @Autowired private TypeResolver typeResolver; - - private ApiKey apiKey() { - return new ApiKey("mykey", "api_key", "header"); - } - - private SecurityContext securityContext() { - return SecurityContext.builder() - .securityReferences(defaultAuth()) - .forPaths(PathSelectors.regex("/anyPath.*")) - .build(); - } - - List defaultAuth() { - AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); - AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; - authorizationScopes[0] = authorizationScope; - return newArrayList(new SecurityReference("mykey", authorizationScopes)); - } - - @Bean - SecurityConfiguration security() { - return new SecurityConfiguration( - "abc", - "123", - "pets", - "petstore", - Constants.HTTP_TENANT_HEADER, - ApiKeyVehicle.HEADER, - "", - ","); + public GroupedOpenApi publicApi() { + return GroupedOpenApi.builder().setGroup("public").pathsToMatch("/**").build(); } - // - // @Bean - // UiConfiguration uiConfig() { - // return new UiConfiguration("validatorUrl"); - // } /** * Can be used to do some initialization at application startup, but does not do anything right now. diff --git a/rest-lib-utils/src/main/resources/application.properties b/rest-lib-utils/src/main/resources/application.properties index 4a115f892..fbed9a8e5 100644 --- a/rest-lib-utils/src/main/resources/application.properties +++ b/rest-lib-utils/src/main/resources/application.properties @@ -20,7 +20,7 @@ #spring.profiles.active=standalone #configurations ignored when the application is run as war (mvn profile container) -server.contextPath=/cia +server.servlet.context-path=/cia server.port = 8092 # Settings for Actuator trace @@ -29,7 +29,10 @@ server.port = 8092 # https://github.com/spring-projects/spring-boot/blob/v1.5.2.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceProperties.java # https://www.dontpanicblog.co.uk/2017/04/14/spring-boot-actuator-trace/ #spring.jackson.date-format=yyyy-MM-dd HH:mm:ss -management.trace.include=REQUEST_HEADERS, RESPONSE_HEADERS, ERRORS, QUERY_STRING +# in spring 1.5.x config was management.trace.include=REQUEST_HEADERS, RESPONSE_HEADERS, ERRORS, QUERY_STRING +# spring 2.x enums valid values: AUTHORIZATION_HEADER,COOKIE_HEADERS,PRINCIPAL,REMOTE_ADDRESS,REQUEST_HEADERS,RESPONSE_HEADERS,SESSION_ID,TIME_TAKEN +management.trace.http.include=REQUEST_HEADERS,RESPONSE_HEADERS + #cia specific configurations