Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package com.zoomint;
  2.  
  3. import org.gradle.api.Plugin;
  4. import org.gradle.api.Project
  5.  
  6. class NvdContainerDepCheckPlugin implements Plugin<Project> {
  7. def final DCUSER = 'dcuser'
  8. def final DCPASS = 'DC-Pass1337!'
  9.  
  10. void apply(Project project) {
  11. def final hostPort = getAvailablePort()
  12.  
  13. def startContainer = project.tasks.register("startContainer", StartNvdDatabaseTask, DCUSER, DCPASS, hostPort)
  14. def stopContainer = project.tasks.register("stopContainer", StopNvdDatabaseTask)
  15.  
  16. project.apply plugin: 'org.owasp.dependencycheck'
  17.  
  18. project.dependencyCheck {
  19. autoUpdate = false // do not update the database, its pre-built
  20. data {
  21. connectionString = "jdbc:h2:tcp://localhost:${hostPort}/odc"
  22. driver = 'org.h2.Driver'
  23. username = DCUSER
  24. password = DCPASS
  25. }
  26. }
  27.  
  28. project.dependencyCheckAnalyze.dependsOn startContainer
  29. project.dependencyCheckAnalyze.finalizedBy stopContainer
  30. project.build.dependsOn project.dependencyCheckAnalyze
  31. }
  32.  
  33. static final int getAvailablePort() {
  34. ServerSocket socket = null
  35. try {
  36. socket = new ServerSocket(0)
  37. return socket.localPort
  38. } finally {
  39. if (socket != null) {
  40. socket.close()
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement