Skip to content

Commit

Permalink
highlight template
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed Jun 7, 2020
1 parent 3352fcd commit 455cb2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions static/assets/js/nodejsscan.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
$(document).ready(function () {


//View file
window.view = function(path, line, filename, scan_hash) {

//View file
window.view = function(path, line, filename, scan_hash, match=null) {
$.post('/view_file', {
path: path,
scan_hash: scan_hash
Expand All @@ -14,6 +14,21 @@ window.view = function(path, line, filename, scan_hash) {
for (i = toarr[0]; i <= toarr[1]; i++) {
expanded.push(i);
}
// highlight if only position is available
if (match){
expanded = []
var pos = JSON.parse(match);
var allLines = result.contents.split("\n");
var filepos = 0;
for (var i = 0; i < allLines.length; i++) {
filepos += allLines[i].length;
if (filepos > pos[0]) {
expanded.push(i);
expanded.push(i+1);
break;
}
}
}
$('#myModal').hide();
$('#fname').text(filename.replace(/</g, "").replace(/>/g, ""));
$('#pth').text(path.replace(/</g, "").replace(/>/g, ""));
Expand Down Expand Up @@ -140,7 +155,5 @@ window.revert = function (scan_hash, finding_hash) {

});
}


});

2 changes: 1 addition & 1 deletion templates/scan_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ <h4 class="panel-title" data-toggle="collapse" href="#tmpl{{ tag|slugify }}cp">
</button>

<button class="btn btn-primary" type="button"
onclick="view('{{ file.file_path | js_escape}}','{{ file.match_position[0] }}','{{ file.file_path | relative | js_escape}}','{{scan_hash}}');">
onclick="view('{{ file.file_path | js_escape}}','0','{{ file.file_path | relative | js_escape}}','{{scan_hash}}', '{{file.match_position}}');">
View File
</button>

Expand Down

0 comments on commit 455cb2e

Please sign in to comment.