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

Fixes the github security errors #411

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 16 additions & 16 deletions frontend/js/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const getChartOptions = (runs, chart_element) => {

const displayGraph = (runs) => {
const element = createChartContainer("#chart-container", "run-energy", runs);

const options = getChartOptions(runs, element);

const chart_instance = echarts.init(element);
Expand Down Expand Up @@ -241,26 +241,26 @@ const displayCITable = (runs, url_params) => {

var run_link = ''
if(source == 'github') {
run_link = `https://github.com/${url_params.get('repo')}/actions/runs/${run_id}`;
run_link = `https://github.com/${escapeString(url_params.get('repo'))}/actions/runs/${escapeString(run_id)}`;
}
else if (source == 'gitlab') {
run_link = `https://gitlab.com/${url_params.get('repo')}/-/pipelines/${run_id}`
run_link = `https://gitlab.com/${escapeString(url_params.get('repo'))}/-/pipelines/${escapeString(run_id)}`
}

const run_link_node = `<a href="${run_link}" target="_blank">${run_id}</a>`
const run_link_node = `<a href="${run_link}" target="_blank">${escapeString(run_id)}</a>`

const created_at = el[3]

const label = el[4]
const duration = el[7]

li_node.innerHTML = `<td class="td-index">${value}</td>\
<td class="td-index">${label}</td>\
li_node.innerHTML = `<td class="td-index">${escapeString(value)}</td>\
<td class="td-index">${escapeString(label)}</td>\
<td class="td-index">${run_link_node}</td>\
<td class="td-index"><span title="${created_at}">${dateToYMD(new Date(created_at))}</span></td>\
<td class="td-index" ${tooltip}>${short_hash}</td>\
<td class="td-index">${cpu}</td>\
<td class="td-index">${duration} seconds</td>`;
<td class="td-index"><span title="${escapeString(created_at)}">${dateToYMD(new Date(created_at))}</span></td>\
<td class="td-index" ${escapeString(tooltip)}>${escapeString(short_hash)}</td>\
<td class="td-index">${escapeString(cpu)}</td>\
<td class="td-index">${escapeString(duration)} seconds</td>`;
document.querySelector("#ci-table").appendChild(li_node);
});
$('table').tablesort();
Expand Down Expand Up @@ -318,17 +318,17 @@ $(document).ready((e) => {
let repo_link = ''

if(badges_data.data[0][8] == 'github') {
repo_link = `https://github.com/${url_params.get('repo')}`;
repo_link = `https://github.com/${escapeString(url_params.get('repo'))}`;
}
else if(badges_data.data[0][8] == 'gitlab') {
repo_link = `https://gitlab.com/${url_params.get('repo')}`;
repo_link = `https://gitlab.com/${escapeString(url_params.get('repo'))}`;
}
//${repo_link}
const repo_link_node = `<a href="${repo_link}" target="_blank">${url_params.get('repo')}</a>`
const repo_link_node = `<a href="${repo_link}" target="_blank">${escapeString(url_params.get('repo'))}</a>`
document.querySelector('#ci-data').insertAdjacentHTML('afterbegin', `<tr><td><strong>Repository:</strong></td><td>${repo_link_node}</td></tr>`)
document.querySelector('#ci-data').insertAdjacentHTML('afterbegin', `<tr><td><strong>Branch:</strong></td><td>${url_params.get('branch')}</td></tr>`)
document.querySelector('#ci-data').insertAdjacentHTML('afterbegin', `<tr><td><strong>Workflow:</strong></td><td>${url_params.get('workflow')}</td></tr>`)
document.querySelector('#ci-data').insertAdjacentHTML('afterbegin', `<tr><td><strong>Branch:</strong></td><td>${escapeString(url_params.get('branch'))}</td></tr>`)
document.querySelector('#ci-data').insertAdjacentHTML('afterbegin', `<tr><td><strong>Workflow:</strong></td><td>${escapeString(url_params.get('workflow'))}</td></tr>`)

displayCITable(badges_data.data, url_params);
chart_instance = displayGraph(badges_data.data)
displayAveragesTable(badges_data.data)
Expand Down
22 changes: 12 additions & 10 deletions frontend/js/helpers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ class GMTMenu extends HTMLElement {
customElements.define('gmt-menu', GMTMenu);

const replaceRepoIcon = (uri) => {
if (uri.startsWith("https://www.github.com") || uri.startsWith("https://github.com")) {
uri = uri.replace("https://www.github.com", '<i class="icon github"></i>');
uri = uri.replace("https://github.com", '<i class="icon github"></i>');
} else if (uri.startsWith("https://www.bitbucket.com") || uri.startsWith("https://bitbucket.com")) {
uri = uri.replace("https://www.bitbucket.com", '<i class="icon bitbucket"></i>');
uri = uri.replace("https://bitbucket.com", '<i class="icon bitbucket"></i>');
} else if (uri.startsWith("https://www.gitlab.com") || uri.startsWith("https://gitlab.com")) {
uri = uri.replace("https://www.gitlab.com", '<i class="icon gitlab"></i>');
uri = uri.replace("https://gitlab.com", '<i class="icon gitlab"></i>');
const replacements = [
{ pattern: /^https:\/\/(www\.)?github\.com/, replacement: '<i class="icon github"></i>' },
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved Hide resolved
{ pattern: /^https:\/\/(www\.)?bitbucket\.com/, replacement: '<i class="icon bitbucket"></i>' },
Fixed Show fixed Hide fixed
{ pattern: /^https:\/\/(www\.)?gitlab\.com/, replacement: '<i class="icon gitlab"></i>' }
Fixed Show fixed Hide fixed
];

for (const { pattern, replacement } of replacements) {
if (pattern.test(uri)) {
return uri.replace(pattern, replacement);
}
}

return uri;
}
};

const showNotification = (message_title, message_text, type='warning') => {
$('body')
Expand Down