Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: address CSP guidelines in JENKINS-74474 and JENKINS-74475 #121

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

maven.buildMavenPackage {
pname = "sysdig-secure-plugin";
version = "3.0.2";
version = "3.0.3";
src = ./.;
mvnHash = "sha256-BXnqTBE27wVP8JpWT6ed597CORhiHw6Ogc2tY6rNCIU=";

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document.addEventListener('DOMContentLoaded', function () {
const dataHolderDiv = document.getElementById('index-data-holder');
if (!dataHolderDiv) {
return;
}

const dataGatesSummaryTable = dataHolderDiv.getAttribute('data-gates-summary-table');
const dataGatesTable = dataHolderDiv.getAttribute('data-gates-table');
const dataSecurityTable = dataHolderDiv.getAttribute('data-security-table');

if (dataGatesSummaryTable != '') {
buildPolicyEvalSummaryTable("#gates_summary_table", dataGatesSummaryTable);
}

if (dataGatesTable != '') {
buildPolicyEvalTable("#gates_table", dataGatesTable);
}

if (dataSecurityTable != '') {
buildSecurityTable("#security_table", dataSecurityTable);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,11 @@
class="table table-striped table-bordered dataTable no-footer"
style="width: 100%;"></table>
</div>
<script type="text/javascript">
buildPolicyEvalSummaryTable("#gates_summary_table", ${it.gateSummary});
</script>
</j:if>

<h3 class="title">Sysdig Secure Policy Evaluation Report</h3>
<table id="gates_table" class="table table-striped table-bordered dataTable no-footer"
style="width: 100%;"></table>
<script type="text/javascript">
buildPolicyEvalTable("#gates_table", "${it.gateOutputUrl}");
</script>
</div>

<j:if test="${!empty(it.cveListingUrl)}">
Expand Down Expand Up @@ -106,10 +100,18 @@
<table id="security_table" class="table table-striped table-bordered dataTable "
style="width: 100%;"></table>
</div>
<script type="text/javascript">
buildSecurityTable("#security_table", "${it.cveListingUrl}");
</script>
</div>

<!--
In order to prevent XSS, we need to hold the data in an HTML element called 'data-holder' and adjunct the script,
that will retrieve the contents of the div, and execute the script on DOMContentLoaded
-->
<div id="index-data-holder"
data-gates-summary-table="${it.gateSummary}"
data-gates-table="${it.gateOutputUrl}"
data-security-table="${it.cveListingUrl}"
/>
<st:adjunct includes="com.sysdig.jenkins.plugins.sysdig.infrastructure.jenkins.vm.ui.SysdigAction.index-script" />
</j:if>
</div>
</div>
Expand All @@ -126,7 +128,6 @@
<br></br>
</j:forEach>
</j:otherwise>

</j:choose>
</l:main-panel>
</l:layout>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
document.addEventListener('DOMContentLoaded', function () {
const summaryDiv = document.getElementById('result-summary-data-holder');
if (!summaryDiv) {
return;
}

const cveListingUrl = summaryDiv.getAttribute('data-cve-listing-url');
const gateOutputUrl = summaryDiv.getAttribute('data-gate-output-url');

getSummaryRecap('#result-summary', cveListingUrl, gateOutputUrl);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<st:include page="scripts.jelly" it="${it}"/>
<script type="text/javascript">
getSummaryRecap('#result-summary', '${it.cveListingUrl}', '${it.gateOutputUrl}');
</script>

<!--
In order to prevent XSS, we need to hold the data in an HTML element called 'data-holder' and adjunct the script,
that will retrieve the contents of the div, and execute the script on DOMContentLoaded
-->
<div id="result-summary-data-holder"
data-cve-listing-url="${it.cveListingUrl}"
data-gate-output-url="${it.gateOutputUrl}">
</div>
<st:adjunct includes="com.sysdig.jenkins.plugins.sysdig.infrastructure.jenkins.vm.ui.SysdigAction.new-engine-summary" />
<div id="result-summary"/>
</j:jelly>
Loading