From 7e7314bbf43a4c98f4e13c3b41e65b9bc598b933 Mon Sep 17 00:00:00 2001
From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com>
Date: Wed, 25 Dec 2024 14:26:05 +0200
Subject: [PATCH 1/4] [JENKINS-74141] Extract inline JavaScript from
`FortifyPlugin/global.jelly`
---
pom.xml | 2 +-
.../fortify/plugin/jenkins/FortifyPlugin/global.jelly | 2 +-
src/main/webapp/refresh-projects.js | 9 ++++++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index dc63459..8a6da97 100644
--- a/pom.xml
+++ b/pom.xml
@@ -123,7 +123,7 @@
org.jenkins-ci.plugins
gradle
- 2.9
+ 2.12.0.1
diff --git a/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/global.jelly b/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/global.jelly
index a98b555..183bf23 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/global.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/global.jelly
@@ -45,7 +45,7 @@
-
+
${progress}
diff --git a/src/main/webapp/refresh-projects.js b/src/main/webapp/refresh-projects.js
index f3c6532..830cc68 100644
--- a/src/main/webapp/refresh-projects.js
+++ b/src/main/webapp/refresh-projects.js
@@ -226,4 +226,11 @@ function disableCtrlURLInput() {
}
}
-window.addEventListener("load", disableCtrlURLInput);
+window.addEventListener("DOMContentLoaded", () => {
+ disableCtrlURLInput();
+
+ document.querySelector("#refreshButton").addEventListener("click", (event) => {
+ const { url, paramList } = event.target.dataset;
+ refreshTemplateList(url, paramList);
+ });
+});
From 212516cddfc65627da05d1d908fb2b7c378a079a Mon Sep 17 00:00:00 2001
From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com>
Date: Wed, 25 Dec 2024 17:03:29 +0200
Subject: [PATCH 2/4] [JENKINS-74137] Extract inline JavaScript from
`FortifyPlugin/config.jelly`
---
.../plugin/jenkins/FortifyPlugin/config.jelly | 24 ++++++++++++-------
src/main/webapp/refresh-projects.js | 9 +++++++
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly
index c39c245..585a962 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/FortifyPlugin/config.jelly
@@ -90,7 +90,8 @@
-
+
${progress}
@@ -102,7 +103,8 @@
-
+
@@ -193,7 +195,8 @@
-
+
${progress}
@@ -205,7 +208,8 @@
-
+
@@ -300,7 +304,8 @@
-
+
${progress}
@@ -312,7 +317,8 @@
-
+
@@ -349,7 +355,8 @@
-
+
${progress}
@@ -361,7 +368,8 @@
-
+
diff --git a/src/main/webapp/refresh-projects.js b/src/main/webapp/refresh-projects.js
index 830cc68..f70c153 100644
--- a/src/main/webapp/refresh-projects.js
+++ b/src/main/webapp/refresh-projects.js
@@ -234,3 +234,12 @@ window.addEventListener("DOMContentLoaded", () => {
refreshTemplateList(url, paramList);
});
});
+
+Behaviour.specify(".fortify-refresh-button", "fortify-refresh-button-behaviour", 0, (button) => {
+ button.addEventListener("click", (event) => {
+ const target = event.target;
+ const { refreshUrl, callback } = target.dataset;
+
+ window[callback](refreshUrl, target);
+ });
+});
From f8766ccffb6fd41192939672d90dd9da9aed0173 Mon Sep 17 00:00:00 2001
From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com>
Date: Thu, 26 Dec 2024 12:29:14 +0200
Subject: [PATCH 3/4] [JENKINS-74138][JENKINS-74139][JENKINS-74140] Extract
inline JavaScript
---
.../fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly | 6 ++++--
.../plugin/jenkins/steps/CloudScanStart/config.jelly | 6 ++++--
.../fortify/plugin/jenkins/steps/FortifyUpload/config.jelly | 6 ++++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly
index d2db507..476b843 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanMbs/config.jelly
@@ -75,7 +75,8 @@
+ class="fortify-refresh-button" data-callback="refreshProjectNames"
+ data-refresh-url="${rootURL}/descriptor/${descriptor.clazz.name}/refreshProjects"/>
@@ -90,7 +91,8 @@
+ class="fortify-refresh-button" data-callback="refreshProjectVersions"
+ data-refresh-url="${rootURL}/descriptor/${descriptor.clazz.name}/refreshVersions"/>
diff --git a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly
index 16b9852..5021d67 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/steps/CloudScanStart/config.jelly
@@ -69,7 +69,8 @@
+ class="fortify-refresh-button" data-callback="refreshProjectNames"
+ data-refresh-url="${rootURL}/descriptor/${descriptor.clazz.name}/refreshProjects"/>
@@ -85,7 +86,8 @@
+ class="fortify-refresh-button" data-callback="refreshProjectVersions"
+ data-refresh-url="${rootURL}/descriptor/${descriptor.clazz.name}/refreshVersions"/>
diff --git a/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly b/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly
index be26249..f8e43e8 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/steps/FortifyUpload/config.jelly
@@ -23,7 +23,8 @@
-
+
${progress}
@@ -36,7 +37,8 @@
-
+
From 05f8ef06fae8db49bdc4ae0ac6d2ec84860de00d Mon Sep 17 00:00:00 2001
From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com>
Date: Thu, 26 Dec 2024 14:11:48 +0200
Subject: [PATCH 4/4] [JENKINS-74136][JENKINS-74142] Extract inline JavaScript
---
.../jenkins/ChartAction/floatingBox.jelly | 35 ++-----------------
.../plugin/jenkins/ChartAction/graph.js | 35 +++++++++++++++++++
.../plugin/jenkins/TableAction/index.jelly | 8 +----
src/main/webapp/refresh-issues.js | 7 ++++
4 files changed, 45 insertions(+), 40 deletions(-)
create mode 100644 src/main/resources/com/fortify/plugin/jenkins/ChartAction/graph.js
diff --git a/src/main/resources/com/fortify/plugin/jenkins/ChartAction/floatingBox.jelly b/src/main/resources/com/fortify/plugin/jenkins/ChartAction/floatingBox.jelly
index 34b8e0d..ce90b02 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/ChartAction/floatingBox.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/ChartAction/floatingBox.jelly
@@ -19,38 +19,7 @@
-
+
+
\ No newline at end of file
diff --git a/src/main/resources/com/fortify/plugin/jenkins/ChartAction/graph.js b/src/main/resources/com/fortify/plugin/jenkins/ChartAction/graph.js
new file mode 100644
index 0000000..1647aa3
--- /dev/null
+++ b/src/main/resources/com/fortify/plugin/jenkins/ChartAction/graph.js
@@ -0,0 +1,35 @@
+document.addEventListener("DOMContentLoaded", () => {
+ const { urlName } = document.querySelector(".fortify-graph-data-holder").dataset;
+
+ var stamp = new Date().getTime();
+ function checkGraphUpdate() {
+ fetch(`${urlName}/checkUpdates`, {
+ method: 'POST',
+ headers: crumb.wrap({
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ }),
+ body: new URLSearchParams({
+ stamp: stamp,
+ })
+ }).then(function(rsp) {
+ if (rsp.ok) {
+ var update = rsp.headers.get('go');
+ if(update == "go") {
+ stamp = new Date().getTime();
+ var image = document.getElementById('nvsGraph');
+ if(image.complete) {
+ var new_image = new Image();
+ new_image.id = "nvsGraph";
+ new_image.src = image.src + "?v=" + stamp;
+ // insert new image and remove old
+ image.parentNode.insertBefore(new_image,image);
+ image.parentNode.removeChild(image);
+ }
+ }
+ // next update in 10 sec
+ window.setTimeout(checkGraphUpdate, 10000);
+ }
+ });
+ }
+ window.setTimeout(checkGraphUpdate, 15000);
+});
diff --git a/src/main/resources/com/fortify/plugin/jenkins/TableAction/index.jelly b/src/main/resources/com/fortify/plugin/jenkins/TableAction/index.jelly
index 6075808..a1293fd 100644
--- a/src/main/resources/com/fortify/plugin/jenkins/TableAction/index.jelly
+++ b/src/main/resources/com/fortify/plugin/jenkins/TableAction/index.jelly
@@ -20,10 +20,7 @@
-
+
@@ -48,9 +45,6 @@
You have to build your project in order to access Fortify Assessment results
-
diff --git a/src/main/webapp/refresh-issues.js b/src/main/webapp/refresh-issues.js
index 9f9d852..97331f7 100644
--- a/src/main/webapp/refresh-issues.js
+++ b/src/main/webapp/refresh-issues.js
@@ -183,3 +183,10 @@
}
window.setTimeout(loadIssues, 0);
}
+
+ document.addEventListener("DOMContentLoaded", () => {
+ window.stamp = new Date().getTime();
+ var { contextUrl, imagesUrl } = document.querySelector(".table-action-data-holder").dataset;
+ window.contextUrl = contextUrl;
+ loadIssueTable(`${imagesUrl}/spinner.gif`);
+ });