Added editor

This commit is contained in:
parallax
2017-03-02 10:07:55 +01:00
parent 7270cb09f3
commit 6ba3a07634
333 changed files with 61201 additions and 0 deletions
+172
View File
@@ -0,0 +1,172 @@
/* CSS declarations go here */
body {
background: url('ros-logo.gif') no-repeat left 50px top 100px;
font-family:Droid-Sans;
color: #cd7e00;
background-color: rgba(0, 0, 0, 0.75);
}
fieldset {
border-radius: 10px;
border-color: #cd7e00;
}
input,textarea {
background-color:rgba(0, 0, 0, 0);
color: white;
height: 18px;
padding: 5px;
margin: 2px;
border-color: #cd7e00;
border-radius: 10px;
}
input:focus,textarea:focus {
background: black;
}
input:hover,textarea:hover {
background: black;
}
button {
background-color:rgba(0, 0, 0, 0);
color: #cd7e00;
height: 28px;
border-color: #cd7e00;
border-radius: 10px;
}
button:hover {
color: #000000;
background-color: #cd7e00;
}
button.active {
color: #000000;
background-color: #cd7e00;
}
.directory {
width: 600px;
}
.selected {
color: #000000;
background-color: #cd7e00;
}
.box {
border-radius: 10px;
border: 2px solid #cd7e00;
padding: 5px;
margin: 2px;
}
.search_pane input {
width: 96.5%;
margin-bottom: 20px;
}
.search_button {
background-color:rgba(0, 0, 0, 0);
width: 35px;
height: 35px;
}
.search_result {
display: flex;
flex-direction: column;
}
.search_result button {
float: right;
}
.search_result textarea {
box-sizing: border-box;
height: 500px;
}
.selectable:hover {
color: #000000;
background-color: #cd7e00;
}
.top_menu {
height: 40px;
}
.left_pane {
order: 1;
width: 40%;
}
.middle_pane {
order: 2;
flex-grow: 1
}
.right_pane {
order: 3;
flex-grow: 1;
}
.bottom_pane {
display: flex;
}
/* Line 1 */
.form-control
{
/*display: block;*/
}
textarea.form-control {
width: 98%;
height: 300px;
}
input.form-control {
width: 600px;
}
label.control-label {
width: 100px;
clear: both;
float:left;
margin-right:15px;
color: white;
}
.help-block {
color: red;
}
.green {
border-color: green;
color:green;
}
.green button {
border-color: green;
color:green;
}
.red {
border-color: red;
color:red;
}
.red button {
border-color: red;
color:red;
}
+228
View File
@@ -0,0 +1,228 @@
<head>
<title>PenText editor</title>
</head>
<body>
{{>main}}
</body>
<template name="main">
<div class="top_menu box">
<button class="edit_findings_button {{findingButtonActive}}" name="edit_findings">EDIT FINDINGS</button>
<button class="edit_non_findings_button {{nonFindingButtonActive}}" name="edit_non_findings">EDIT NON-FINDINGS</button>
</div>
{{#if editModeIs "findings"}}
<div class="box">{{> findings_settings}}</div>
<div class="bottom_pane">
<fieldset class="left_pane box">
<legend>Findings</legend>
{{> findings_pane}}
</fieldset>
{{#if findingsEditorActive}}
<div class="middle_pane box">{{> findings_editor}}</div>
{{/if}}
</div>
{{/if}}
{{#if editModeIs "non_findings"}}
<div class="box">{{> non_findings_settings}}</div>
<div class="bottom_pane">
<fieldset class="left_pane box">
<legend>Non-Findings</legend>
{{> findings_pane}}
</fieldset>
{{#if nonFindingsEditorActive}}
<div class="middle_pane box">{{> non_findings_editor}}</div>
{{/if}}
</div>
{{/if}}
</template>
<template name="findings_settings">
<form class="update_findings_directory">
<label for="findings_directory">Pentest Findings directory: </label>
<input id="findings_directory"
name="findings_directory"
class="directory"
value="{{findings_directory}}"/>
<button type="submit">UPDATE</button>
</form>
<form class="update_findings_library_directory">
<label for="findings_directory">Findings library directory: </label>
<input id="findings_library_directory"
name="library_findings_directory"
class="directory"
value="{{findings_library_directory}}"/>
<button type="submit">UPDATE</button>
</form>
</template>
<template name="non_findings_settings">
<form class="update_non_findings_directory">
<label for="non_findings_directory">Pentest Non-Findings directory: </label>
<input id="non_findings_directory"
name="non_findings_directory"
class="directory"
value="{{non_findings_directory}}"/>
<button type="submit">UPDATE</button>
</form>
<form class="update_non_findings_library_directory">
<label for="non_findings_library_directory">Non-Findings library directory: </label>
<input id="non_findings_library_directory"
name="non_findings_library_directory"
class="directory"
value="{{non_findings_library_directory}}"/>
<button type="submit">UPDATE</button>
</form>
</template>
<template name="finding">
<div id="{{filename}}" class="search_result selectable box {{bordercolor}}" title="{{tooltip}}">
<div class="search_result_title">
<span>{{{filename}}}</span>
{{#if typeIs "findings"}}
{{> use_finding_button}}
{{/if}}
{{#if typeIs "library_findings"}}
{{> use_library_finding_button }}
{{/if}}
{{#if typeIs "non_findings"}}
{{> use_non_finding_button}}
{{/if}}
{{#if typeIs "library_non_findings"}}
{{> use_library_non_finding_button }}
{{/if}}
</div>
{{#if shouldShowContent}}
<textarea>{{{raw}}}</textarea>
{{/if}}
</div>
</template>
<template name="use_finding_button">
<button title="Use this finding in editor">&#9658;</button>
</template>
<template name="use_library_finding_button">
<button title="Use this library finding to update the fields of a pentests finding in the editor">&#9658;</button>
</template>
<template name="use_non_finding_button">
<button title="Use this non-finding in editor">&#9658;</button>
</template>
<template name="use_library_non_finding_button">
<button title="Use this library non-finding to update the fields of a pentests non-finding in the editor">&#9658;</button>
</template>
<template name="findings_editor">
{{#autoForm collection="Findings" doc=getSelectedFinding type="update" id="findingForm"}}
<!--{{> afQuickField name="filename"}}-->
{{> afQuickField name="id"}}
{{> afQuickField name="threat_level" options="allowed"}}
{{> afQuickField name="type"}}
{{> afQuickField name="title"}}
{{> afQuickField name="description"}}
{{> afQuickField name="technical_description"}}
{{> afQuickField name="impact"}}
{{> afQuickField name="recommendation"}}
<div>
<button type="submit" class="btn btn-primary">UPDATE</button>
</div>
{{/autoForm}}
</template>
<template name="non_findings_editor">
{{#autoForm collection="NonFindings" doc=getSelectedNonFinding type="update" id="nonfindingForm"}}
<!--{{> afQuickField name="filename"}}-->
{{> afQuickField name="id"}}
{{> afQuickField name="title"}}
{{> afQuickField name="description"}}
<div>
<button type="submit" class="btn btn-primary">UPDATE</button>
</div>
{{/autoForm}}
</template>
<template name="findings_pane">
<div class="box">
<button class="pentest {{isPentestTabActive}}">PENTEST</button>
<button class="library {{isLibraryTabActive}}">LIBRARY</button>
</div>
<div>
{{#if isPentestTabActive}}
{{#if editModeIs "findings"}}
{{> findings}}
{{/if}}
{{# if editModeIs "non_findings"}}
{{> non_findings}}
{{/if}}
{{/if}}
{{#if isLibraryTabActive}}
{{# if editModeIs "findings"}}
{{> library_findings}}
{{/if}}
{{# if editModeIs "non_findings"}}
{{> library_non_findings }}
{{/if}}
{{/if}}
</div>
</template>
<template name="findings">
<div class="search_pane">
{{> EasySearch.Input attributes=properties index=FindingsIndex timeout="200" count=10000}}
{{#EasySearch.Each index=FindingsIndex}}
{{> finding}}
{{/EasySearch.Each}}
{{#EasySearch.IfNoResults index=FindingsIndex}}
<div class="no-results">No results found!</div>
{{/EasySearch.IfNoResults}}
</div>
</template>
<template name="library_findings">
<div class="search_pane">
{{> EasySearch.Input attributes=properties index=LibraryFindingsIndex timeout="200" count=10000}}
{{#EasySearch.Each index=LibraryFindingsIndex}}
{{> finding}}
{{/EasySearch.Each}}
{{#EasySearch.IfNoResults index=LibraryFindingsIndex}}
<div class="no-results">No results found!</div>
{{/EasySearch.IfNoResults}}
</div>
</template>
<template name="non_findings">
<div class="search_pane">
{{> EasySearch.Input attributes=properties index=NonFindingsIndex timeout="200" count=10000}}
{{#EasySearch.Each index=NonFindingsIndex}}
{{> finding}}
{{/EasySearch.Each}}
{{#EasySearch.IfNoResults index=NonFindingsIndex}}
<div class="no-results">No results found!</div>
{{/EasySearch.IfNoResults}}
</div>
</template>
<template name="library_non_findings">
<div class="search_pane">
{{> EasySearch.Input attributes=properties index=LibraryNonFindingsIndex timeout="200" count=10000}}
{{#EasySearch.Each index=LibraryNonFindingsIndex}}
{{> finding}}
{{/EasySearch.Each}}
{{#EasySearch.IfNoResults index=LibraryNonFindingsIndex}}
<div class="no-results">No results found!</div>
{{/EasySearch.IfNoResults}}
</div>
</template>
+414
View File
@@ -0,0 +1,414 @@
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import { ReactiveVar } from 'meteor/reactive-var';
import { FindingsIndex } from '../imports/api/findings.js'
import { NonFindingsIndex } from '../imports/api/nonfindings';
import { LibraryFindingsIndex } from '../imports/api/library_findings.js'
import { LibraryNonFindingsIndex } from '../imports/api/library_non_findings.js'
import Findings from '../imports/api/findings';
import NonFindings from '../imports/api/nonfindings';
import { Settings } from '../imports/api/settings.js';
import './main.html';
Meteor.subscribe("snippets");
Meteor.subscribe("oneReport");
Meteor.subscribe("settings");
Meteor.subscribe("findings");
Meteor.subscribe("library_findings");
Meteor.subscribe("non_findings");
Meteor.subscribe("library_non_findings");
Findings.attachSchema(new SimpleSchema({
// filename: {
// type: String,
// label: "Filename",
// min: 1,
// max: 200
// },
id: {
type: String,
label: "ID",
min: 1,
max: 200,
},
threat_level: {
type: String,
allowedValues: [
"Low",
"Moderate",
"Elevated",
"High",
"Extreme"
],
label: "Threat level",
},
type: {
type: String,
label: "Type",
min: 1,
max: 200,
},
title: {
type: String,
label: "Title",
min: 1,
max: 200,
},
description: {
type: String,
label: "Description",
min: 1,
autoform: {
rows: 5
},
},
technical_description: {
type: String,
label: "Technical Description",
min: 1,
autoform: {
rows: 5
},
},
impact: {
type: String,
min: 1,
label: "Impact",
autoform: {
rows: 5
},
},
recommendation: {
type: String,
min: 1,
label: "Recommendation",
autoform: {
rows: 5
},
}
}));
NonFindings.attachSchema({
// filename: {
// type: String,
// label: "Filename",
// min: 1,
// max: 200
// },
id: {
type: String,
label: "ID",
min: 1,
max: 200,
},
title: {
type: String,
label: "Title",
min: 1,
max: 200,
},
description: {
type: String,
label: "Description",
min: 1,
autoform: {
rows: 5
},
},
});
/** ******************************** EDITOR PANE HELPERS *************************************/
/**
* FINDINGS_EDITOR
*/
Template.findings_editor.helpers({
getFormType:function () {
var finding_id = Session.get("selected_finding");
return finding_id ? "update" : "insert";
},
getSelectedFinding:function () {
return Findings.findOne(Session.get("selected_finding"));
}
});
/**
* NON-FINDINGS EDITOR
*/
Template.non_findings_editor.helpers({
getFormType:function () {
var finding_id = Session.get("selected_finding");
return finding_id ? "update" : "insert";
},
getSelectedNonFinding:function () {
return NonFindings.findOne(Session.get("selected_non_finding"));
}
});
// Template.editor.event = {
// 'click .btn_reset': function () {
// AutoForm.resetForm('findingForm');
// Session.set("selected_finding", null);
// }
// };
/**
* MAIN
*/
Template.main.events = {
'click .edit_findings_button': function (event, template) {
Session.set("edit_mode", "findings");
},
'click .edit_non_findings_button': function (event, template) {
Session.set("edit_mode", "non_findings");
},
};
Template.main.created = function () {
Session.set("edit_mode", null);
};
Template.main.helpers({
editMode:function() {
return Session.get("edit_mode");
},
findingButtonActive:function(){
return Session.get("edit_mode") == "findings" ? "active" : "";
},
nonFindingButtonActive:function(){
return Session.get("edit_mode") == "non_findings" ? "active" : "";
},
findingsEditorActive: function () {
return Session.get("selected_finding");
},
nonFindingsEditorActive: function () {
return Session.get("selected_non_finding");
},
editModeIs: function (mode) {
return Session.get("edit_mode") == mode;
},
});
/**
* Findings Settings
*/
Template.findings_settings.helpers({
findings_directory: function () {
return Settings.findOne({_id: "findings_directory"}).value;
},
findings_library_directory: function () {
return Settings.findOne({_id: "library_findings_directory"}).value;
}
});
Template.findings_settings.events({
"submit .update_findings_directory": function(event){
event.preventDefault();
var newvalue = event.target.findings_directory.value;
Settings.update({_id: "findings_directory"}, {$set: {value: newvalue}});
Session.set("selected_finding", null); // Prevents editor from emptying out on update
},
"submit .update_findings_library_directory": function(event){
event.preventDefault();
var newvalue = event.target.library_findings_directory.value;
Settings.update({_id: "library_findings_directory"}, {$set: {value: newvalue}});
}
});
/**
* Non-Findings Settings
*/
Template.non_findings_settings.helpers({
non_findings_directory: function () {
return Settings.findOne({_id: "non_findings_directory"}).value;
},
non_findings_library_directory: function () {
return Settings.findOne({_id: "non_findings_library_directory"}).value;
}
});
Template.non_findings_settings.events({
"submit .update_non_findings_directory": function(event){
event.preventDefault();
var newvalue = event.target.non_findings_directory.value;
Settings.update({_id: "non_findings_directory"}, {$set: {value: newvalue}});
Session.set("selected_non_finding", null); // Prevents editor from emptying out on update
},
"submit .update_non_findings_library_directory": function(event){
event.preventDefault();
var newvalue = event.target.non_findings_library_directory.value;
Settings.update({_id: "non_findings_library_directory"}, {$set: {value: newvalue}});
}
});
/**
* FINDINGS_PANE
*/
Template.findings_pane.created = function () {
this.activeTab = new ReactiveVar("pentest");
};
Template.findings_pane.helpers({
isPentestTabActive:function () {
return Template.instance().activeTab.get() == "pentest" ? "active" : null;
},
isLibraryTabActive:function () {
return Template.instance().activeTab.get() == "library" ? "active" : null
},
editModeIs: function (mode) {
return Session.get("edit_mode") == mode;
},
editMode: function() {
return Session.get("edit_mode");
}
});
Template.findings_pane.events({
'click .pentest': function (event, template) {
template.activeTab.set("pentest");
},
'click .library': function (event, template) {
template.activeTab.set("library");
},
});
/**
* FINDINGS
*/
Template.findings.helpers({
FindingsIndex: () => FindingsIndex,
properties: () => { return {placeholder: "Enter filter term .."}},
});
/**
* LIBRARY FINDINGS
*/
Template.library_findings.helpers({
LibraryFindingsIndex: () => LibraryFindingsIndex,
properties: () => { return {placeholder: "Enter filter term .."}}
});
/**
* LIBRARY NON FINDINGS
*/
Template.library_non_findings.helpers({
LibraryNonFindingsIndex: () => LibraryNonFindingsIndex,
properties: () => { return {placeholder: "Enter filter term .."}}
});
/**
* NON-FINDINGS
*/
Template.non_findings.helpers({
NonFindingsIndex: () => NonFindingsIndex,
properties: () => { return {placeholder: "Enter filter term .."}}
});
/**
* FINDING
*/
Template.finding.events = {
'click .search_result_title': function (e) {
if (Session.get(this._id)) {
Session.set(this._id, false);
} else {
Session.set(this._id, true);
}
}
};
Template.finding.helpers({
shouldShowContent:function () {
return Session.get(this._id);
},
bordercolor:function() {
switch (this.valid) {
case true:
return "green";
case false:
return "red";
default:
return "";
}
},
tooltip:function() {
switch (this.valid) {
case true:
return "This file is a valid XML file. All elements can be copied to the editor";
case false:
return "This file is not a valid XML file. This means that not all elements can be copied to the editor. If your are missing text, manually copy and paste it from the raw view.";
default:
return "";
}
},
typeIs: function (type) {
return Template.parentData(1).index.config.name == type;
}
});
/**
* USE FINDING BUTTON
*/
Template.use_finding_button.events({
"click": function () {
Session.set("selected_finding", this._id);
return false;
}
});
Template.use_library_finding_button.events({
"click": function () {
var id = Session.get("selected_finding");
if (!id) return false;
Findings.update(id, {
$set: {
threat_level: this.threat_level,
type: this.type,
title: this.title,
description: this.description,
technical_description: this.technical_description,
impact: this.impact,
recommendation: this.recommendation
}
});
return false;
}
});
/**
* LIBRARY NON FINDING BUTTON
*/
Template.use_library_non_finding_button.events({
"click": function () {
var id = Session.get("selected_non_finding");
console.log(id);
if (!id) return false;
NonFindings.update(id, {
$set: {
title: this.title,
description: this.description,
}
});
return false;
}
});
Template.use_non_finding_button.events({
"click": function () {
Session.set("selected_non_finding", this._id);
return false;
}
});