Skip to content

Commit 9285f8a

Browse files
authored
Merge pull request #221 from aau-network-security/feature/challenge-profiles-#000
Feature/challenge profiles #000
2 parents f6d6c25 + 05e7aef commit 9285f8a

File tree

9 files changed

+7316
-5207
lines changed

9 files changed

+7316
-5207
lines changed

client/daemon_grpc_web_pb.js

+588-107
Large diffs are not rendered by default.

client/daemon_pb.js

+5,371-4,972
Large diffs are not rendered by default.

client/src/Pages/Challenges.vue

+466-113
Large diffs are not rendered by default.

client/src/Pages/Home.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@
268268
});
269269
call.on('status', function(status) {
270270
that.loaderIsActive = false;
271-
if (status['metadata']['grpc-message'] == "") {
271+
if (!status['metadata']['grpc-message']) {
272272
that.success = "Event Successfully Created!"
273-
that.listEvent()
273+
that.listEvent();
274274
}else{
275275
that.error = status['metadata']['grpc-message']
276276
if (status.details === 'token contains an invalid number of segments') {
@@ -302,7 +302,7 @@
302302
});
303303
call.on('status', function(status) {
304304
that.loaderIsActive = false
305-
if (status['metadata']['grpc-message'] == "") {
305+
if (!status['metadata']['grpc-message']) {
306306
that.success = "Action successfully completed!"
307307
that.listEvent()
308308
}else{
@@ -335,8 +335,8 @@
335335
});
336336
call.on('status', function(status) {
337337
that.loaderIsActive = false
338-
if (status['metadata']['grpc-message'] == "") {
339-
that.success = "Event Successfully Stop!"
338+
if (!status['metadata']['grpc-message']) {
339+
that.success = "Event Successfully Stopped!"
340340
that.listEvent()
341341
}else{
342342
that.error = status['metadata']['grpc-message']

client/src/Pages/Profiles.vue

+784
Large diffs are not rendered by default.

client/src/components/EventModal.vue

+63-10
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,32 @@
286286
</div>
287287
</div>
288288
<template v-slot:label>
289-
<b>Choose your Challenges:</b>
290-
<b-form-checkbox
291-
v-model="selectAllChallenges"
292-
aria-describedby="challengesTag"
293-
aria-controls="challengesTag"
294-
@change="toggleAllChallenges"
295-
>
296-
{{ selectAllChallenges ? 'Un-select All' : 'Select All' }}
297-
</b-form-checkbox>
289+
<b-row>
290+
<b-col>
291+
<b>Choose your Challenges:</b>
292+
<b-form-checkbox
293+
v-model="selectAllChallenges"
294+
aria-describedby="challengesTag"
295+
aria-controls="challengesTag"
296+
@change="toggleAllChallenges"
297+
>
298+
{{ selectAllChallenges ? 'Un-select All' : 'Select All' }}
299+
</b-form-checkbox>
300+
</b-col>
301+
<b-col>
302+
<b-col md="12" style="padding-left: 0;"><b>Choose a profile:</b></b-col>
303+
<b-form-select @change="onProfileSelect()" v-model="selectedProfile">
304+
<b-form-select-option :value="null">No profile</b-form-select-option>
305+
<b-form-select-option
306+
v-for="(profile) in profiles"
307+
:key="profile"
308+
:value="profile"
309+
>
310+
{{ profile.name }} <template v-if="profile.secret">(Secret)</template>
311+
</b-form-select-option>
312+
</b-form-select>
313+
</b-col>
314+
</b-row>
298315
</template>
299316
</b-form-group>
300317
</b-col>
@@ -399,6 +416,8 @@ export default {
399416
secretKey: '',
400417
selectedFrontends: null,
401418
categories: [],
419+
profiles: [],
420+
selectedProfile: null,
402421
cat: '', childrenChallenges: '', isDisabled: false,
403422
disabledDates: {
404423
to: new Date(Date.now() - 8640000)
@@ -410,6 +429,7 @@ export default {
410429
this.getFrontends();
411430
this.getCategories();
412431
this.handleButtons();
432+
this.getProfiles();
413433
},
414434
watch: {
415435
eventCapacity: function () {
@@ -420,6 +440,39 @@ export default {
420440
},
421441
},
422442
methods: {
443+
onProfileSelect: function() {
444+
this.selectedChallenges = []
445+
const that = this
446+
if (this.selectedProfile != null) {
447+
this.selectedProfile.challenges.forEach(function(challenge){
448+
that.selectedChallenges.push(challenge.tag)
449+
})
450+
}
451+
//window.console.log("Profile selected is", this.selectedProfile)
452+
},
453+
getProfiles: function() {
454+
const that = this
455+
let getRequest = new Empty
456+
daemonclient.listProfiles(getRequest, {Token: localStorage.getItem("user")}, (err, response) => {
457+
window.console.log(err)
458+
let profileListObj = response.getProfilesList();
459+
profileListObj.forEach(function (element){
460+
let name = element.getName()
461+
let secret = element.getSecret()
462+
let challengesListObj = element.getChallengesList()
463+
let challenges = []
464+
challengesListObj.forEach(function (element){
465+
let tag = element.getTag()
466+
let name = element.getName()
467+
let challenge = {tag: tag, name: name}
468+
challenges.push(challenge)
469+
})
470+
let profile = {name: name, secret: secret, challenges: challenges}
471+
//window.console.log("Got profile", profile)
472+
that.profiles.push(profile)
473+
})
474+
})
475+
},
423476
resetDescriptionWindow: function() {
424477
// window.console.log("Resetting description window") // Debugging
425478
// Emptying/resetting the description field
@@ -600,7 +653,7 @@ export default {
600653
}
601654
})
602655
})
603-
window.console.log(that.categories)
656+
//window.console.log(that.categories)
604657
});
605658
},
606659
handlePrev : function () {

client/src/components/Navbar.vue

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<b-collapse id="nav-collapse" class="mr-auto" is-nav>
1414
<b-navbar-nav>
1515
<b-nav-item href="/challenges">Challenges</b-nav-item>
16+
<b-nav-item href="/profiles">Profiles</b-nav-item>
1617
<b-nav-item href="/users">Users</b-nav-item>
1718
<b-nav-item href="/vms">VMs</b-nav-item>
1819
<b-nav-item href="/graphs">Graphs</b-nav-item>

client/src/router.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import HomePage from './Pages/Home'
55
import LoginPage from './Pages/Login'
66
import Teams from "./Pages/Teams";
77
import Challenges from "./Pages/Challenges";
8+
import Profiles from "./Pages/Profiles";
89
import VMs from "./Pages/VMs";
910
import TeamFlags from "./Pages/TeamFlags";
1011
import TeamAction from "./Pages/TeamAction";
@@ -25,6 +26,7 @@ export const router = new Router({
2526
{ name: 'flags',path: '/events/:tag/:id/flags', component: TeamFlags},
2627
{ name: 'team', path: '/events/:tag/:id', component: TeamAction },
2728
{ name: 'challenges', path: '/challenges', component: Challenges},
29+
{ name: 'profiles', path: '/profiles', component: Profiles},
2830
{ name: 'users', path: '/users', component: Users},
2931
{ name: 'vms', path: '/vms', component: VMs },
3032
{ name: 'graphs', path: '/graphs', component: Graphs},

proto/daemon.proto

+36
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ service Daemon {
4040
rpc MonitorHost (Empty) returns (stream MonitorHostResponse) {}
4141
rpc Version (Empty) returns (VersionResponse) {}
4242
rpc ListCategories (Empty) returns (ListCategoriesResponse) {}
43+
rpc SaveProfile (SaveProfileRequest) returns (stream ProfileStatus) {}
44+
rpc DeleteProfile (DeleteProfileRequest) returns (stream ProfileStatus) {}
45+
rpc EditProfile (SaveProfileRequest) returns (stream ProfileStatus) {}
46+
rpc ListProfiles (Empty) returns (ListProfilesResponse) {}
4347
}
4448

4549

@@ -287,6 +291,38 @@ message ListExercisesResponse {
287291
repeated Exercise exercises = 1;
288292
}
289293

294+
message ListProfilesResponse {
295+
message Profile {
296+
message Challenge {
297+
string tag = 1;
298+
string name = 2;
299+
}
300+
string name = 1;
301+
bool secret = 2;
302+
repeated Challenge challenges = 3;
303+
}
304+
repeated Profile profiles = 1;
305+
}
306+
307+
message SaveProfileRequest {
308+
message Challenge {
309+
string tag = 1;
310+
string name = 2;
311+
}
312+
string name = 1;
313+
bool secret = 2;
314+
repeated Challenge challenges = 3;
315+
}
316+
317+
message DeleteProfileRequest {
318+
string name = 1;
319+
}
320+
321+
message ProfileStatus {
322+
string profile = 1;
323+
string status = 2;
324+
}
325+
290326
message ListCategoriesResponse {
291327
message Category {
292328
string tag = 1;

0 commit comments

Comments
 (0)