Skip to content

Commit d3b214b

Browse files
committed
Fix linting errors
1 parent 4178f3f commit d3b214b

8 files changed

+181
-166
lines changed

.eslintrc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ module.exports = {
3939
"no-undef": "off",
4040
"no-unused-vars": "off",
4141
"no-use-before-define": "off",
42+
"no-useless-escape": "off",
4243
"no-var": "off",
4344
"object-shorthand": "off",
44-
"prefer-const": "off"
45+
"prefer-const": "off",
46+
"prefer-destructuring": "off"
4547
}
4648
};

templates/abilities.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ <h2>Abilities</h2>
454454
access: {}
455455
};
456456

457-
this.addExecutorToAbility('before')
457+
this.addExecutorToAbility('before');
458458
this.showAbilityModal = true;
459459
},
460460

templates/configurations.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ <h2>Configuration</h2>
117117
let requestBody = {
118118
value: pluginName,
119119
prop: 'plugin'
120-
}
120+
};
121121

122122
apiV2('PATCH', '/api/v2/config/main', requestBody).then((response) => {
123123
toast('Plugin enabled! Restart the server for the changes to take effect.', true);
@@ -127,7 +127,7 @@ <h2>Configuration</h2>
127127
console.error(error);
128128
});
129129
},
130-
130+
131131
};
132132
}
133133

templates/contacts.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h2>Contacts</h2>
4848

4949
downloadContactReport(contactName) {
5050
// TODO: Update to V2
51-
downloadReport('/api/rest', `${contactName}_report`, { index: "contact", contact: contactName });
51+
downloadReport('/api/rest', `${contactName}_report`, { index: 'contact', contact: contactName });
5252
}
5353
};
5454
}

templates/exfilled_files.html

+30-14
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ <h2>Exfilled Files</h2>
44
<p>
55
Exfilled files are uploaded from an agent on a host to the server during an operation are by default stored on the server at <span x-text="exfilDir"></span>.
66
<br>
7-
You can view and download the files here.
7+
If an operation has exfilled files, you can view and download the files here.
88
</p>
99
</div>
1010
<hr>
1111
<div>
1212
<form>
13-
<div class="field">
14-
<label class="label">Select an operation</label>
15-
<div class="control">
16-
<div class="select is-small">
13+
<div id="select-operation" class="field has-addons">
14+
<label class="label">Select an operation &nbsp;&nbsp;&nbsp;</label>
15+
<div class="control is-expanded">
16+
<div class="select is-small is-fullwidth">
1717
<select x-on:change="loadFiles()" x-model="selectedOperationId">
1818
<option value="" selected>(all)</option>
1919
<template x-for="operation of operations" :key="operation.id">
@@ -24,7 +24,7 @@ <h2>Exfilled Files</h2>
2424
</div>
2525
</div>
2626
</form>
27-
<div class="buttons">
27+
<div class="buttons" x-show="numFiles !== 0">
2828
<button class="button is-primary is-small" @click="toggleAllFiles(selectedFiles.length < numFiles)">
2929
<span x-text="selectedFiles.length < numFiles ? 'Select' : 'Unselect'"></span>&nbsp;All Files
3030
</button>
@@ -33,7 +33,10 @@ <h2>Exfilled Files</h2>
3333
<span>Download</span>
3434
</button>
3535
</div>
36-
<ul class="tree" x-show="files">
36+
<p x-show="numFiles === 0">
37+
The selected operation has exfilled files to show.
38+
</p>
39+
<ul class="tree" x-show="numFiles !== 0">
3740
<li class="root">
3841
<span class="icon is-small"><i class="far fa-folder-open"></i></span>
3942
<span x-text="exfilDir"></span>
@@ -52,6 +55,9 @@ <h2>Exfilled Files</h2>
5255
</label>
5356
</li>
5457
</template>
58+
<li x-show="!Object.keys(files[agentName]).length">
59+
(none)
60+
</li>
5561
</ul>
5662
</li>
5763
</template>
@@ -83,7 +89,7 @@ <h2>Exfilled Files</h2>
8389
},
8490

8591
loadFiles() {
86-
restRequest('POST', { 'index': 'exfil_files', 'operation_id': this.selectedOperationId }, (files) => {
92+
restRequest('POST', { index: 'exfil_files', operation_id: this.selectedOperationId }, (files) => {
8793
this.files = JSON.parse(files);
8894
this.numFiles = 0;
8995
if (this.selectedOperationId) {
@@ -109,7 +115,11 @@ <h2>Exfilled Files</h2>
109115

110116
toggleFile(filePath) {
111117
let index = this.selectedFiles.indexOf(filePath);
112-
index >= 0 ? this.selectedFiles.splice(index, 1) : this.selectedFiles.push(filePath);
118+
if (index >= 0) {
119+
this.selectedFiles.splice(index, 1);
120+
} else {
121+
this.selectedFiles.push(filePath);
122+
}
113123
},
114124

115125
isFileSelected(filePath) {
@@ -118,7 +128,8 @@ <h2>Exfilled Files</h2>
118128

119129
toggleAllFiles(selectAll) {
120130
if (!selectAll) {
121-
return this.selectedFiles = [];
131+
this.selectedFiles = [];
132+
return;
122133
}
123134

124135
Object.keys(this.files).forEach((agent) => {
@@ -131,11 +142,11 @@ <h2>Exfilled Files</h2>
131142
downloadFiles() {
132143
this.selectedFiles.forEach((filePath) => {
133144
let filename = filePath.split(/[\/\\]/);
134-
filename = filename[filename.length -1];
135-
let uri = "/file/download_exfil?file=" + btoa(filePath);
145+
filename = filename[filename.length - 1];
146+
let uri = `/file/download_exfil?file=${btoa(filePath)}`;
136147
let downloadAnchorNode = document.createElement('a');
137-
downloadAnchorNode.setAttribute("href", uri);
138-
downloadAnchorNode.setAttribute("download", filename);
148+
downloadAnchorNode.setAttribute('href', uri);
149+
downloadAnchorNode.setAttribute('download', filename);
139150
document.body.appendChild(downloadAnchorNode);
140151
downloadAnchorNode.click();
141152
downloadAnchorNode.remove();
@@ -148,6 +159,11 @@ <h2>Exfilled Files</h2>
148159
</script>
149160

150161
<style scoped>
162+
#select-operation {
163+
max-width: 800px;
164+
margin: 0 auto;
165+
}
166+
151167
ul.tree {
152168
margin: 0px 0px 0px 20px;
153169
list-style: none !important;

templates/objectives.html

+66-67
Original file line numberDiff line numberDiff line change
@@ -194,84 +194,83 @@ <h4>Goals</h4>
194194
</div>
195195

196196
<script>
197-
198-
function alpineObjectives() {
199-
return {
200-
objectives: [],
201-
adversaries: [],
202-
selectedObjectiveId: '',
203-
selectedObjective: {},
204-
isEditing: false,
197+
function alpineObjectives() {
198+
return {
199+
objectives: [],
200+
adversaries: [],
201+
selectedObjectiveId: '',
202+
selectedObjective: {},
203+
isEditing: false,
205204

206-
OPERATOR_TYPES: ['<', '>', '<=', '>=', 'in', '*', '=='],
205+
OPERATOR_TYPES: ['<', '>', '<=', '>=', 'in', '*', '=='],
207206

208-
showAssignmentsModal: false,
207+
showAssignmentsModal: false,
209208

210-
// Input validation
211-
requiredFields: ['name', 'description', 'goals'],
212-
fieldErrors: [],
209+
// Input validation
210+
requiredFields: ['name', 'description', 'goals'],
211+
fieldErrors: [],
213212

214-
initPage() {
215-
apiV2('GET', '/api/v2/objectives').then((objectives) => {
216-
this.objectives = objectives;
217-
return apiV2('GET', '/api/v2/adversaries');
218-
}).then((adversaries) => {
219-
this.adversaries = adversaries;
220-
}).catch((error) => {
221-
toast('Error loading page', false);
222-
console.error(error);
223-
});
224-
},
213+
initPage() {
214+
apiV2('GET', '/api/v2/objectives').then((objectives) => {
215+
this.objectives = objectives;
216+
return apiV2('GET', '/api/v2/adversaries');
217+
}).then((adversaries) => {
218+
this.adversaries = adversaries;
219+
}).catch((error) => {
220+
toast('Error loading page', false);
221+
console.error(error);
222+
});
223+
},
225224

226-
createObjective() {
227-
this.objectives.push({
228-
id: uuidv4(),
229-
name: '',
230-
description: '',
231-
goals: []
232-
});
233-
this.selectedObjective = this.objectives[this.objectives.length - 1];
234-
this.addGoal();
235-
this.isEditing = true;
236-
},
225+
createObjective() {
226+
this.objectives.push({
227+
id: uuidv4(),
228+
name: '',
229+
description: '',
230+
goals: []
231+
});
232+
this.selectedObjective = this.objectives[this.objectives.length - 1];
233+
this.addGoal();
234+
this.isEditing = true;
235+
},
237236

238-
addGoal() {
239-
this.selectedObjective.goals.push({
240-
achieved: false,
241-
count: 0,
242-
operator: this.OPERATOR_TYPES[0],
243-
target: "",
244-
value: ""
245-
});
246-
},
237+
addGoal() {
238+
this.selectedObjective.goals.push({
239+
achieved: false,
240+
count: 0,
241+
operator: this.OPERATOR_TYPES[0],
242+
target: '',
243+
value: ''
244+
});
245+
},
247246

248-
saveObjective() {
249-
this.fieldErrors = validateInputs(this.selectedObjective, this.requiredFields);
250-
if (this.fieldErrors.length) return;
247+
saveObjective() {
248+
this.fieldErrors = validateInputs(this.selectedObjective, this.requiredFields);
249+
if (this.fieldErrors.length) return;
251250

252-
apiV2('PUT', `/api/v2/objectives/${this.selectedObjective.id}`, this.selectedObjective).then((response) => {
253-
this.isEditing = false;
254-
toast('Saved objective', true);
255-
}).catch((error) => {
256-
toast('Error saving objective', false);
257-
console.error(error);
258-
});
259-
},
260-
261-
cancelEditing() {
251+
apiV2('PUT', `/api/v2/objectives/${this.selectedObjective.id}`, this.selectedObjective).then((response) => {
262252
this.isEditing = false;
263-
apiV2('GET', `/api/v2/objectives/${this.selectedObjective.id}`).then((objective) => {
264-
this.selectedObjective = objective;
265-
}).catch((error) => {
266-
toast('Error canceling changes, please close and reopen this page', false);
267-
console.error(error);
268-
});
269-
}
253+
toast('Saved objective', true);
254+
}).catch((error) => {
255+
toast('Error saving objective', false);
256+
console.error(error);
257+
});
258+
},
270259

271-
};
272-
}
260+
cancelEditing() {
261+
this.isEditing = false;
262+
apiV2('GET', `/api/v2/objectives/${this.selectedObjective.id}`).then((objective) => {
263+
this.selectedObjective = objective;
264+
}).catch((error) => {
265+
toast('Error canceling changes, please close and reopen this page', false);
266+
console.error(error);
267+
});
268+
}
269+
270+
};
271+
}
273272

274-
// # sourceURL=objectives.js
273+
// # sourceURL=objectives.js
275274
</script>
276275

277276
<style>

0 commit comments

Comments
 (0)