Skip to content

Commit

Permalink
feat: run=1, autoscan url
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Apr 15, 2021
1 parent 1200677 commit 6124238
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/ReportHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default {
if (this.$route.query["fields"]) args += ` --report-fields ${this.$route.query["fields"]}`;
// console.log('args: ', args);
return `/scan?url=${scanOptions.url}&args=${args}`;
return `/scan?url=${scanOptions.url}&args=${args}&run=1`;
},
rescanUrlTitle() {
Expand Down
28 changes: 25 additions & 3 deletions pages/scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ export default {
currentScanQueue: '',
currentScanPercent: 0,
showLog: false,
autoscan: false,
};
},
Expand Down Expand Up @@ -616,7 +617,13 @@ export default {
if (this.routerProcess) return;
if (this.$route.query["fields"]) return; // ignore params from viewer
for (let paramName of ['url', 'urls', 'args', 'serverUrl', 'preset']) {
// reset form to default
for (let formName in this.scanDefaultForm) {
this.form[formName] = this.scanDefaultForm[formName];
}
// add params from query
for (let paramName of ['url', 'urls', 'args', 'serverUrl', 'preset', 'run']) {
let val = this.$route.query[paramName];
if (val) {
if (paramName === 'url' && val.includes('/reports/')) continue;
Expand Down Expand Up @@ -821,6 +828,12 @@ export default {
if (msg.includes('Finish audit')) {
this.currentScanPage = '';
this.currentScanPercent = 0;
// open report after scan
if (this.autoscan) {
this.autoscan = false;
this.$router.push({ path: this.reportUrl });
}
}
if (msg.includes('Pending...')) {
Expand Down Expand Up @@ -915,8 +928,9 @@ export default {
async mounted() {
this.socket = this.$nuxtSocket({
channel: "/",
reconnection: true,
reconnectionDelayMax: 3000,
reconnection: true, // not used?
reconnectionDelayMax: 3000, // not used?
persist: true, // causes disconnects?
teardown: false,
});
Expand All @@ -929,6 +943,10 @@ export default {
this.currentScanPercent = 0;
this.currentScanQueue = 0;
this.auth();
if (this.autoscan) {
setTimeout(this.sendTask, 500);
}
});
this.socket.on("disconnect", () => {
Expand All @@ -954,6 +972,10 @@ export default {
});
this.updateFormFromQuery(); // update form after localStorage
if (this.$route.query.run == '1') {
this.autoscan = true;
}
},
Expand Down

0 comments on commit 6124238

Please sign in to comment.