Skip to content

Commit

Permalink
Traceability relations removable from web app and filtering out task_…
Browse files Browse the repository at this point in the history
…asset for removable traces list
  • Loading branch information
Shamal Faily committed Jan 4, 2017
1 parent e5f9987 commit bf4fc4d
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 26 deletions.
2 changes: 2 additions & 0 deletions cairis/core/MySQLDatabaseProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2750,6 +2750,8 @@ def removableTraces(self,environmentName):
fromName = traceRow[FROM_ID_COL]
toObjt = traceRow[TO_OBJT_COL]
toName = traceRow[TO_ID_COL]
if (fromObjt == 'task' and toObjt == 'asset'):
continue
traces.append((fromObjt,fromName,toObjt,toName))
curs.close()
return traces
Expand Down
107 changes: 107 additions & 0 deletions cairis/web/dist/js/cairis/traceability.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Authors: Shamal Faily */

'use strict';

$("#traceabilityClick").click(function(){
activeElement("objectViewer");
$('#filtercontent').hide();
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crossDomain: true,
url: serverIP + "/api/dimensions/table/environment",
success: function (envs) {
fillOptionMenu("fastTemplates/editTraceabilityOptions.html", "#objectViewer", null, true, true, function () {
$('#theEnvironmentName option').remove();
$.each(envs, function(idx,env) {
$('#theEnvironmentName').append($("<option></option>").attr("value",env).text(env));
});
});
$('#theEnvironmentName').val(envs[0]);
$('#theEnvironmentName').trigger('change');
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
})
});

var mainContent = $('#objectViewer');
mainContent.on("change",'#theEnvironmentName',function() {
var envName = $('#theEnvironmentName').val();
$.ajax({
type: "GET",
dataType: "json",
accept: "application/json",
data: {
session_id: String($.session.get('sessionID'))
},
crossDomain: true,
url: serverIP + "/api/traces/environment/" + encodeURIComponent(envName),
success: function (trs) {
$('#theTraces').find('tbody').empty();
$.each(trs, function(idx,t) {
appendTrace(t);
});
},
error: function (xhr, textStatus, errorThrown) {
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
})
});

function appendTrace(t) {
$("#theTraces").find("tbody").append('<tr><td class="deleteTrace"><i class="fa fa-minus"></i></td><td class="trace-rows">'+ t.theFromObject + '</td><td>' + t.theFromName + '</td><td>' + t.theToObject + '</td><td>' + t.theToName +'</td></tr>');
};

mainContent.on('click','td.deleteTrace',function() {
var tRow = $(this).closest("tr");
var fromObjt = tRow.find("td:eq(1)").text();
var fromName = tRow.find("td:eq(2)").text();
var toObjt = tRow.find("td:eq(3)").text();
var toName = tRow.find("td:eq(4)").text();

$.ajax({
type: "DELETE",
dataType: "json",
contentType: "application/json",
accept: "application/json",
crossDomain: true,
processData: false,
origin: serverIP,
url: serverIP + "/api/traces/from_type/" + encodeURIComponent(fromObjt) + "/from_name/" + encodeURIComponent(fromName) + "/to_type/" + encodeURIComponent(toObjt) + "/to_name/" + encodeURIComponent(toName) + "?session_id=" + $.session.get('sessionID'),
success: function (data) {
tRow.remove();
showPopup(true);
},
error: function (xhr, textStatus, errorThrown) {
var error = JSON.parse(xhr.responseText);
showPopup(false, String(error.message));
debugLogger(String(this.url));
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown);
}
});
});
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editAssetsOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ul>
<div id="Summary">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Asset</label>
<input type="text" class="optionsInput assetUpdate form-control" id="theName" name="theName" style="width: 75%;" data-error="Asset name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editAttackerOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div><br/>
<div class="right" style="width: 75%;">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Attacker</label>
<input class="optionsInput form-control" type="text" name="theName" id="theName" style="width: 100%;" data-error="Attacker name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editCountermeasureOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ul>
<div id="summary">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Countermeasure</label>
<input class="optionsInput countermeasureUpdate form-control" type="text" name="theName" id="theName" style="float: right; width: 75%" date-error="Name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editDocumentReferenceOptions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form role="form" id="editDocumentReferenceOptionsForm" xmlns="http://www.w3.org/1999/html" >

<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Reference</label>
<input class="optionsInput form-control" type="text" name="theName" id="theName" style="width: 75%" data-error="Document Reference name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editDomainPropertyOptions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form role="form" id="editDomainPropertyOptionsForm" xmlns="http://www.w3.org/1999/html" >

<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Domain Property</label>
<input class="optionsInput form-control" type="text" name="theName" id="theName" date-error="Domain Property name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editEnvironmentOptions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form role="form" id="editEnvironmentOptionsform" xmlns="http://www.w3.org/1999/html">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Environment</label>
<input class="optionsInput form-control" type="text" name="theName" id="theName" data-error="Environment name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editExternalDocumentOptions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form role="form" id="editExternalDocumentOptionsForm" xmlns="http://www.w3.org/1999/html" >

<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Document</label>
<input class="optionsInput form-control" type="text" name="theName" id="theName" style="width: 75%" data-error="External Document name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editGoalsOptions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form role="form" xmlns="http://www.w3.org/1999/html" id="editGoalOptionsForm" class="gearOptions">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Goal</label>
<input class="optionsInput form-control" type="text" id="theName" name="theName" data-error="Goal name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editObstaclesOptions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form role="form" xmlns="http://www.w3.org/1999/html" id="editObstacleOptionsForm" class="gearOptions">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Obstacle</label>
<input class="optionsInput form-control" type="text" id="theName" name="theName" data-error="Obstacle name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editResponseOptions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form role="form" id="editResponseOptionsform" xmlns="http://www.w3.org/1999/html">
<div class="form-group">
<label for="theResponseName" class="control-label">Name</label>
<label for="theResponseName" class="control-label">Response</label>
<input class="optionsInput form-control" type="text" name="theResponseName" id="theResponseName" style="width: 75%;" readonly>
</div>
<div class="form-group">
Expand Down
23 changes: 13 additions & 10 deletions cairis/web/fastTemplates/editRiskOptions.html
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
<form role="form" id="editRisksForm">
<div class="row form-group">
<div class="col-md-3">
<label for="theName" class="control-label">Name</label>
<div class="col-md-2">
<label for="theName" class="control-label">Risk</label>
</div>
<div class="col-md-9">
<div class="col-md-11">
<input class="optionsInput form-control" type="text" name="theName" id="theName" data-error="Risk name required" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="col-md-2">
<label for="theTags" class="control-label">Tags</label>
</div>
<div class="col-md-9">
<div class="col-md-11">
<input class="optionsInput form-control" type="text" name="theTags" id="theTags">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="col-md-2">
<label for="theThreatNames" class="control-label">Threat</label>
</div>
<div class="col-md-9">
<div class="col-md-11">
<select class="right riskDetailsChanger form-control" id="theThreatNames">
</select>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="col-md-2">
<label for="theVulnerabilityNames" class="control-label">Vulnerability</label>
</div>
<div class="col-md-9">
<div class="col-md-11">
<select class="right riskDetailsChanger form-control" id="theVulnerabilityNames">
</select>
<div class="help-block with-errors"></div>
</div>
</div>
</br>
<div>
<table class="clickable-table" id="theRiskEnvironments" style="width: 100%;">
<thead>
Expand All @@ -46,19 +47,21 @@
</tbody>
</table>
</div>
</br>
<div>
<label for="rating" class="control-label" >Rating</label>
<input class="optionsInput form-control" type="text" name="rating" id="rating" readonly>
</div>
<div>
<table class="clickable-table" id="theResponses" style="width: 100%;">
<thead>
<tr><th>Response</th><th>Unmit. Score</th><th>Mit. Score</th></tr>
<tr><th>Response</th><th>Score (Pre Mitigation)</th><th>Score (Post Mitigation)</th></tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</br>
<div class="form-group center-block">
<button type="submit" class="btn btn-primary" id="UpdateRisk">Update</button>
<button type="submit" class="btn btn-primary" id="editMisusedCase">Edit Misuse Case</button>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editRoleOptions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form role="form" id="editRoleOptionsform" xmlns="http://www.w3.org/1999/html" >

<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Role</label>
<input class="optionsInput form-control" type="text" name="theName" id="theName" style="width: 75%;" data-error="Role name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editTaskOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ul>
<div id="summary">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Task</label>
<input class="optionsInput taskUpdate form-control" type="text" name="theName" id="theName" style="width: 75%" data-error="Task name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editThreatOptions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form role="form" id="editThreatOptionsform" xmlns="http://www.w3.org/1999/html" >

<div class="form-group">
<label for="theThreatName" class="control-label">Name</label>
<label for="theThreatName" class="control-label">Threat</label>
<input class="optionsInput form-control" type="text" name="theThreatName" id="theThreatName" style="width: 75%;" data-error="Threat name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
18 changes: 18 additions & 0 deletions cairis/web/fastTemplates/editTraceabilityOptions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<form role="form" id="editTraceabilityOptionsForm" xmlns="http://www.w3.org/1999/html" >
<div class="panel panel-default control-group form-group">
<div class="form-group">
<label for="theEnvironmentName" class="control-label">Name</label>
<select class="optionsInput form-control" name="theEnvironmentName" id="theEnvironmentName" style="width: 100%;">
</select>
</div>
<div class="form-group">
<table class="clickable-table scrollableTable" id="theTraces">
<thead>
<tr><th style="width: 15px;"></th><th>From</th><th>Name</th><th>To</th><th>Name</th></tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</form>
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editUseCaseOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</ul>
<div id="summary">
<div class="form-group">
<label for="theName" class="control-label">Name</label>
<label for="theName" class="control-label">Use Case</label>
<input class="optionsInput usecaseUpdate form-control" type="text" name="theName" id="theName" data-error="Name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cairis/web/fastTemplates/editVulnerabilityOptions.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form role="form" id="editVulnerabilityOptionsform" xmlns="http://www.w3.org/1999/html" >

<div class="form-group">
<label for="theVulnerabilityName" class="control-label">Name</label>
<label for="theVulnerabilityName" class="control-label">Vulnerability</label>
<input class="optionsInput form-control" type="text" name="theVulnerabilityName" id="theVulnerabilityName" style="width: 75%;" data-error="Vulnerability name is required" required>
<div class="help-block with-errors"></div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion cairis/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<li><a id="taskModelClick" href="#">Task</a></li>
<li><a id="personaModelClick" href="#">Persona</a></li>
<li><a id="locationsModelClick" href="#">Locations</a></li>
<li><a id="traceabilityClick" href="#">Traceability</a></li>
</ul>
</li>
<li class="dropdown messages-menu">
Expand Down Expand Up @@ -746,7 +747,7 @@ <h4 class="modal-title">Add Interface</h4>
<script>
LazyLoad.js(["dist/js/cairis/Cairis-UI.js","dist/js/cairis/buttonclicks.js", "dist/js/cairis/Cairis.js", "dist/js/cairis/readFile.js",
"dist/js/cairis/threats.js", "dist/js/cairis/attackers.js", "dist/js/cairis/personas.js", "dist/js/cairis/assets.js", "dist/js/cairis/templateassets.js","dist/js/cairis/templaterequirements.js","dist/js/cairis/templategoals.js","dist/js/cairis/goals.js", "dist/js/cairis/projectSettings.js", "dist/js/cairis/tasks.js", "dist/js/cairis/domainproperties.js", "dist/js/cairis/obstacles.js", "dist/js/cairis/countermeasures.js", "dist/js/cairis/usecases.js","dist/js/cairis/vulnerabilities.js","dist/js/cairis/architecturalpatterns.js","dist/js/cairis/requirements.js",
"dist/js/cairis/risks.js", "dist/js/cairis/fileImport.js", "dist/js/cairis/fileExport.js", "dist/js/cairis/responses.js","dist/js/cairis/dependencies.js","dist/js/cairis/genDoc.js","dist/js/cairis/findobjt.js","dist/js/cairis/externaldocuments.js","dist/js/cairis/documentreferences.js","dist/js/cairis/personacharacteristics.js","dist/js/cairis/homeSettings.js","dist/js/cairis/roles.js","dist/js/cairis/environments.js","dist/js/cairis/valuetypes.js","dist/js/cairis/locations.js",
"dist/js/cairis/risks.js", "dist/js/cairis/fileImport.js", "dist/js/cairis/fileExport.js", "dist/js/cairis/responses.js","dist/js/cairis/dependencies.js","dist/js/cairis/genDoc.js","dist/js/cairis/findobjt.js","dist/js/cairis/externaldocuments.js","dist/js/cairis/documentreferences.js","dist/js/cairis/personacharacteristics.js","dist/js/cairis/homeSettings.js","dist/js/cairis/roles.js","dist/js/cairis/environments.js","dist/js/cairis/valuetypes.js","dist/js/cairis/locations.js","dist/js/cairis/traceability.js",
"dist/js/cairis/SVGhandler.js","dist/js/objects/jsonDefaultObjects.js"], function () {

console.log("All Cairis JS loaded");
Expand Down

0 comments on commit bf4fc4d

Please sign in to comment.