Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/SA-validate-function-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDThales committed Jun 7, 2024
2 parents 89f5449 + d8d2a1d commit df544f9
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 16 deletions.
25 changes: 21 additions & 4 deletions app/src/electron/request-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,13 @@ const validateClasses = () => {
if (ref === null) return
let foundSupportingAsset = SupportingAsset.find(obj => obj.supportingAssetId == ref);

if (foundSupportingAsset.businessAssetRef.length == 0 || foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size || !checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) || foundSupportingAsset.supportingAssetName == ''){
return false
if (
foundSupportingAsset.businessAssetRef.length == 0 ||
foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size ||
!checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) ||
foundSupportingAsset.supportingAssetName == ''
){
return false
}
return true
};
Expand All @@ -305,7 +310,13 @@ const validateClasses = () => {
const checkVulnerabilityRef = (ref,supportingAssetRef) =>{
if (ref === null) return false
found = Vulnerability.find(obj => obj.vulnerabilityId === ref.vulnerabilityId);
if (!found || !found.supportingAssetRef.includes(supportingAssetRef)||!checkSupportingAssetRefArray(found.supportingAssetRef) || found.vulnerabilityName === '' || found.vulnerabilityDescription === '') return false
if (
!found ||
!found.supportingAssetRef.includes(supportingAssetRef) ||
!checkSupportingAssetRefArray(found.supportingAssetRef) ||
found.vulnerabilityName === '' ||
found.vulnerabilityDescription === ''
) return false
return true
};

Expand All @@ -325,7 +336,13 @@ const validateClasses = () => {

const validateRiskDescription = (risk) => {
const { threatAgent, threatVerb, businessAssetRef, supportingAssetRef, motivation } = risk;
if (threatAgent === '' || threatVerb === '' || ! checkBusinessAssetRef(businessAssetRef) || ! checkSupportingAssetRef(supportingAssetRef) || motivation === ''){
if (
threatAgent === '' ||
threatVerb === '' ||
! checkBusinessAssetRef(businessAssetRef) ||
! checkSupportingAssetRef(supportingAssetRef) ||
motivation === ''
){
return false;
} else return true;
};
Expand Down
27 changes: 23 additions & 4 deletions app/src/tabs/Report/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,14 @@
if (ref === null) return
let foundSupportingAsset = existSupportingAsset(ref)

if (foundSupportingAsset == null || foundSupportingAsset.businessAssetRef.length == 0 || foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size || !checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) || foundSupportingAsset.supportingAssetName == ''){
return false
if (
foundSupportingAsset == null ||
foundSupportingAsset.businessAssetRef.length == 0 ||
foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size ||
!checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) ||
foundSupportingAsset.supportingAssetName == ''
){
return false
}
return true
};
Expand All @@ -194,7 +200,13 @@
const checkVulnerabilityRef = (ref,supportingAssetRef) =>{
if (ref === null) return false
found = fetchedData.Vulnerability.find(obj => obj.vulnerabilityId === ref);
if (!found || !found.supportingAssetRef.includes(supportingAssetRef)||!checkSupportingAssetRefArray(found.supportingAssetRef) || found.vulnerabilityName === '' || found.vulnerabilityDescription === '') return false
if (
!found ||
!found.supportingAssetRef.includes(supportingAssetRef) ||
!checkSupportingAssetRefArray(found.supportingAssetRef) ||
found.vulnerabilityName === '' ||
found.vulnerabilityDescription === ''
) return false
return true
};

Expand All @@ -214,7 +226,14 @@

const validateRiskName = (risk) => {
const { threatAgent, threatVerb, businessAssetRef, supportingAssetRef, motivation,riskAttackPaths } = risk;
if (threatAgent === '' || threatVerb === '' || ! checkBusinessAssetRef(businessAssetRef) || ! checkSupportingAssetRef(supportingAssetRef) || ! checkRiskAttackPaths(riskAttackPaths,supportingAssetRef) || motivation === ''){
if (
threatAgent === '' ||
threatVerb === '' ||
! checkBusinessAssetRef(businessAssetRef) ||
! checkSupportingAssetRef(supportingAssetRef) ||
! checkRiskAttackPaths(riskAttackPaths,supportingAssetRef) ||
motivation === ''
){
return '#FF0000';
} else return '#000000';
};
Expand Down
27 changes: 23 additions & 4 deletions app/src/tabs/Risks/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,14 @@ function enableInteract(){
if (ref === null) return
let foundSupportingAsset = existSupportingAsset(ref)

if (foundSupportingAsset == null || foundSupportingAsset.businessAssetRef.length == 0 || foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size || !checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) || foundSupportingAsset.supportingAssetName == ''){
return false
if (
foundSupportingAsset == null ||
foundSupportingAsset.businessAssetRef.length == 0 ||
foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size ||
!checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) ||
foundSupportingAsset.supportingAssetName == ''
){
return false
}
return true
};
Expand All @@ -236,7 +242,13 @@ function enableInteract(){
const checkVulnerabilityRef = (ref,supportingAssetRef) =>{
if (ref === null) return false
found = vulnerabilities.find(obj => obj.vulnerabilityId === ref);
if (!found || !found.supportingAssetRef.includes(supportingAssetRef)||!checkSupportingAssetRefArray(found.supportingAssetRef) || found.vulnerabilityName === '' || found.vulnerabilityDescription === '') return false
if (
!found ||
!found.supportingAssetRef.includes(supportingAssetRef) ||
!checkSupportingAssetRefArray(found.supportingAssetRef) ||
found.vulnerabilityName === '' ||
found.vulnerabilityDescription === ''
) return false
return true
};

Expand All @@ -256,7 +268,14 @@ function enableInteract(){

const validateRiskName = (risk) => {
const { threatAgent, threatVerb, businessAssetRef, supportingAssetRef, motivation,riskAttackPaths } = risk;
if (threatAgent === '' || threatVerb === '' || ! checkBusinessAssetRef(businessAssetRef) || ! checkSupportingAssetRef(supportingAssetRef) || ! checkRiskAttackPaths(riskAttackPaths,supportingAssetRef) || motivation === ''){
if (
threatAgent === '' ||
threatVerb === '' ||
! checkBusinessAssetRef(businessAssetRef) ||
! checkSupportingAssetRef(supportingAssetRef) ||
! checkRiskAttackPaths(riskAttackPaths,supportingAssetRef) ||
motivation === ''
){
return '#FF0000';
} else return '#000000';
};
Expand Down
12 changes: 10 additions & 2 deletions app/src/tabs/Supporting Assets/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
};

const validateSAName = (sa) => {
if (sa.businessAssetRef.length == 0 || sa.businessAssetRef.length !== new Set(sa.businessAssetRef).size || !checkBusinessAssetRefArray(sa.businessAssetRef) || sa.supportingAssetName == ''){
if (
sa.businessAssetRef.length == 0 ||
sa.businessAssetRef.length !== new Set(sa.businessAssetRef).size ||
!checkBusinessAssetRefArray(sa.businessAssetRef) ||
sa.supportingAssetName == ''
){
return '#FF0000';
} else return '#000000';
};
Expand Down Expand Up @@ -116,7 +121,10 @@

// Update the design of the invalid selects
$(`${matrixTable}-${id} td.matrix-sa-ba div select`).map((key,item) => (
!item.value || item.value == "null" || mappingDuplicate[item.value] > 1 ? item.setAttribute('style', `border-color : red; border-width: 3px`): item.setAttribute('style', `border-color : black; border-width: 1px`)
!item.value ||
item.value == "null" ||
mappingDuplicate[item.value] > 1 ?
item.setAttribute('style', `border-color : red; border-width: 3px`): item.setAttribute('style', `border-color : black; border-width: 1px`)
))
}

Expand Down
13 changes: 11 additions & 2 deletions app/src/tabs/Vulnerabilities/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@
const supportingAssetRef = rowData.supportingAssetRef
const vulnerabilityDescription = rowData.vulnerabilityDescription
const vulnerabilityName = rowData.vulnerabilityName
if (supportingAssetsData.length === 0 || supportingAssetRef.length === 0 || !checkSupportingAssetRefArray(supportingAssetRef) || vulnerabilityDescription === '' || vulnerabilityName === '') {
if (
supportingAssetsData.length === 0 ||
supportingAssetRef.length === 0 ||
!checkSupportingAssetRefArray(supportingAssetRef) ||
vulnerabilityDescription === '' ||
vulnerabilityName === ''
) {
cell.getElement().style.color = '#FF0000';
}
else {
Expand Down Expand Up @@ -148,7 +154,10 @@
if (ref === null) return
let foundSupportingAsset = fetchedData.SupportingAsset.find(obj => obj.supportingAssetId == ref);

if (foundSupportingAsset.businessAssetRef.length == 0 || foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size || !checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) || foundSupportingAsset.supportingAssetName == ''){
if (foundSupportingAsset.businessAssetRef.length == 0 ||
foundSupportingAsset.businessAssetRef.length !== new Set(foundSupportingAsset.businessAssetRef).size ||
!checkBusinessAssetRefArray(foundSupportingAsset.businessAssetRef) ||
foundSupportingAsset.supportingAssetName == ''){
return false
}
return true
Expand Down

0 comments on commit df544f9

Please sign in to comment.