Skip to content

Commit 022c819

Browse files
authored
Merge pull request #640 from akto-api-security/develop
Develop
2 parents 602f80e + 82faf95 commit 022c819

File tree

25 files changed

+497
-71
lines changed

25 files changed

+497
-71
lines changed

apps/dashboard/src/main/java/com/akto/action/quick_start/QuickStartAction.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,11 @@ public String saveLoadBalancers() {
154154
if (!AwsStack.getInstance().checkIfStackExists(MirroringStackDetails.getStackName())) {
155155
this.isFirstSetup = true;
156156
try {
157-
Map<String, String> parameters = new HashMap<String, String>() {
158-
{
159-
put("MongoIp", System.getenv("AKTO_MONGO_CONN"));
160-
put("KeyPair", System.getenv("EC2_KEY_PAIR"));
161-
put("SourceLBs", extractLBs());
162-
put("SubnetId", System.getenv("EC2_SUBNET_ID"));
163-
}
164-
};
157+
Map<String, String> parameters = new HashMap<>();
158+
parameters.put("MongoIp", System.getenv("AKTO_MONGO_CONN"));
159+
parameters.put("KeyPair", System.getenv("EC2_KEY_PAIR"));
160+
parameters.put("SourceLBs", extractLBs());
161+
parameters.put("SubnetId", System.getenv("EC2_SUBNET_ID"));
165162
String template = convertStreamToString(AwsStack.class
166163
.getResourceAsStream("/cloud_formation_templates/akto_aws_mirroring.template"));
167164
List<Tag> tags = Utils.fetchTags(DashboardStackDetails.getStackName());
@@ -174,11 +171,8 @@ public String saveLoadBalancers() {
174171
} else {
175172
this.isFirstSetup = false;
176173
try {
177-
Map<String, String> updatedEnvVars = new HashMap<String, String>() {
178-
{
179-
put("ELB_NAMES", extractLBs());
180-
}
181-
};
174+
Map<String, String> updatedEnvVars = new HashMap<>();
175+
updatedEnvVars.put("ELB_NAMES", extractLBs());
182176
String functionName = AwsStack.getInstance().fetchResourcePhysicalIdByLogicalId(MirroringStackDetails.getStackName(), MirroringStackDetails.CREATE_MIRROR_SESSION_LAMBDA);
183177
UpdateFunctionRequest ufr = new UpdateFunctionRequest(updatedEnvVars);
184178
Lambda.getInstance().updateFunctionConfiguration(functionName, ufr);

apps/dashboard/src/main/resources/cloud_formation_templates/akto_aws_mirroring.template

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/dashboard/web/src/apps/dashboard/layouts/LayoutWithTabs.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@
5757
tabs: obj.arrR,
5858
description: obj.strN,
5959
defaultTabName: obj.strN,
60-
tabsContent: obj.objN
60+
tabsContent: obj.objN,
61+
tab: obj.strN
6162
},
6263
data () {
6364
return {
64-
tabName: null
65+
tabName: parseInt(this.tab) || null
6566
}
6667
},
6768
methods: {

apps/dashboard/web/src/apps/dashboard/views/observe/inventory/components/TestsSelector.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
<spinner v-if="loading"/>
33
<a-card v-else title="Configure test" icon="$fas_cog" class="tests-selector-container">
44
<div class="mx-8 my-4">
5-
<div class="d-flex">
5+
<div v-if="!authPresent">
6+
Please set an authentication mechanism <a target="_blank" class="clickable-link" href="/dashboard/testing/active?tab=1">here</a> before you test any APIs.
7+
</div>
8+
<div :class="disableLinkClass">
9+
<div class="d-flex" >
610
<div class="name-div">Name: </div>
711
<name-input :defaultName="collectionName" :defaultSuffixes="nameSuffixes" @changed="setTestName" />
812
</div>
@@ -58,7 +62,7 @@
5862
</div>
5963

6064
<schedule-box @schedule="emitTestSelection" class="mt-2"/>
61-
65+
</div>
6266
</div>
6367
</a-card>
6468
</template>
@@ -67,6 +71,7 @@
6771
6872
import marketplaceApi from '../../../marketplace/api'
6973
import issuesApi from '../../../issues/api'
74+
import testingApi from '../../../testing/api'
7075
import Spinner from '@/apps/dashboard/shared/components/Spinner'
7176
import ScheduleBox from '@/apps/dashboard/shared/components/ScheduleBox'
7277
import func from '@/util/func'
@@ -96,7 +101,9 @@ export default {
96101
startTimestamp: func.timeNow(),
97102
selectedCategory: null,
98103
globalCheckbox: false,
99-
testName: ""
104+
testName: "",
105+
authPresent: false,
106+
disableLinkClass: 'disable-div'
100107
}
101108
},
102109
mounted() {
@@ -111,7 +118,12 @@ export default {
111118
_this.mapCategoryToSubcategory = _this.populateMapCategoryToSubcategory()
112119
})
113120
})
114-
121+
testingApi.fetchAuthMechanismData().then(resp => {
122+
if(resp.authMechanism){
123+
this.authPresent = true;
124+
this.disableLinkClass = ''
125+
}
126+
})
115127
116128
},
117129
methods: {
@@ -246,4 +258,11 @@ export default {
246258
margin: auto 8px auto 0
247259
font-size: 14px
248260
font-weight: 500
261+
262+
.clickable-link
263+
color: #6200ea !important
264+
265+
.disable-div
266+
pointer-events: none
267+
opacity: 0.4
249268
</style>

apps/dashboard/web/src/apps/dashboard/views/testing/PageTesting.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<layout-with-tabs title="API Testing" class="page-testing" :tabs='["Test results", "User config", "Roles"]'>
2+
<layout-with-tabs title="API Testing" class="page-testing" :tabs='["Test results", "User config", "Roles"]' :tab="tab">
33
<template slot="Test results">
44
<div class="py-8">
55
<div>
@@ -40,7 +40,7 @@
4040
<p> 1 </p>
4141
</div>
4242
<div>
43-
<h3> Inject hard-coded auth token </h3>
43+
<h3> Inject hard-coded attacker auth token </h3>
4444
</div>
4545
</div>
4646
<!-- <div>
@@ -83,7 +83,7 @@
8383
</div>
8484

8585
<div>
86-
<h3> Automate auth token generation </h3>
86+
<h3> Automate attacker auth token generation </h3>
8787
</div>
8888
</div>
8989

@@ -153,6 +153,7 @@ import ApiCollectionGroup from '@/apps/dashboard/shared/components/menus/ApiColl
153153
import LoginStepBuilder from './components/token/LoginStepBuilder'
154154
import TokenAutomation from './components/token/TokenAutomation'
155155
import HelpTooltip from '@/apps/dashboard/shared/components/help/HelpTooltip'
156+
import obj from "@/util/obj";
156157
157158
export default {
158159
name: "PageTesting",
@@ -172,7 +173,7 @@ export default {
172173
LogFetch
173174
},
174175
props: {
175-
176+
tab: obj.strN
176177
},
177178
data() {
178179
return {

apps/dashboard/web/src/apps/dashboard/views/testing/components/TestResultsDialog.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@
106106
</div>
107107
<div style="margin-left: 24px">
108108
<div class="d-flex jc-sb mr-3">
109-
<span class="description-title mt-4">Test response matches {{ percentageMatch }}% with original API response</span>
109+
<span class="description-title mt-4">
110+
Test response matches {{ percentageMatch }}% with original API response
111+
112+
<v-chip v-if="isVulnerableAttempt" :style="{ 'height': '18px !important' }" class="ml-2 mr-2" color="rgba(255, 0, 0, 0.5)" text-color="#FFFFFF">
113+
Vulnerable Attempt
114+
</v-chip>
115+
</span>
116+
<span>
117+
</span>
110118
<v-btn v-if="messagesBasic.length > 1" icon @click="nextClicked">
111119
<v-icon>$fas_angle-double-right</v-icon>
112120
</v-btn>
@@ -232,7 +240,7 @@ export default {
232240
let testSubType = this.testingRunResult["testSubType"]
233241
let singleTypeInfos = this.testingRunResult["singleTypeInfos"]
234242
let highlightPaths = this.buildHighlightPaths(singleTypeInfos);
235-
return this.testingRunResult["testResults"].map(x => { return { message: x.originalMessage, title: testSubType, highlightPaths: highlightPaths, errors: x.errors, percentageMatch: x.percentageMatch } })
243+
return this.testingRunResult["testResults"].map(x => { return { message: x.originalMessage, title: testSubType, highlightPaths: highlightPaths, errors: x.errors, percentageMatch: x.percentageMatch, vulnerable: x.vulnerable } })
236244
},
237245
jsonBasic: function () {
238246
if (this.testingRunResult == null) return null
@@ -254,6 +262,11 @@ export default {
254262
return null
255263
}
256264
},
265+
isVulnerableAttempt: function () {
266+
if (this.testingRunResult == null) return null
267+
let currentMessage = this.messagesAdvance[this.currentIndex]
268+
return currentMessage ? currentMessage["vulnerable"] : null
269+
},
257270
jsonAdvance: function () {
258271
if (this.testingRunResult == null) return null
259272
let currentMessage = this.messagesAdvance[this.currentIndex]

apps/dashboard/web/src/apps/dashboard/views/testing/components/TestingRunResults.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@
2525
@dateClicked=dateClicked
2626
/>
2727
<div class="testing-results-header" v-if="currentTest">
28-
<span>Test results: </span>
29-
<span>{{selectedDateStr()}}</span>
28+
<div>
29+
<span>Test results: </span>
30+
<span>{{selectedDateStr()}}</span>
31+
</div>
32+
<div style="display: flex; text-transform: capitalize;">
33+
<div v-if="this.currentTest.state">Test status: {{this.currentTest.state.toLowerCase()}}</div>
34+
<div v-if="this.currentTest.state === 'SCHEDULED' || this.currentTest.state === 'RUNNING' " style="padding-left: 6px; padding-top: 4px;">
35+
<v-progress-circular indeterminate color="primary" :size="12" :width="1.5"></v-progress-circular>
36+
</div>
37+
<span v-if="this.currentTest.state === 'COMPLETED'" style="padding-top: 4px;">
38+
<v-icon color="green" :size="14">$fas_check-circle</v-icon>
39+
</span>
40+
</div>
3041
</div>
3142
<simple-table
3243
:headers="testingRunResultsHeaders"
@@ -354,4 +365,7 @@ export default {
354365
font-size: 14px
355366
font-weight: 500
356367
color: #47466A80
368+
display: flex
369+
justify-content: space-between
370+
padding-right: 24px
357371
</style>

apps/dashboard/web/src/apps/main/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ const router = new Router({
7070
components: {
7171
default: PageTesting
7272
},
73+
props: {
74+
default: route => ({
75+
tab: route.query.tab
76+
})
77+
},
7378
children: [
7479
{
7580
path: 'active',

apps/dashboard/web/src/util/func.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default {
147147
var d = date.getDate();
148148
var m = strArray[date.getMonth()];
149149
var y = date.getFullYear();
150-
return m + ' ' + d + ', ' + (needYear ? y: '' ) + ' ' + date.toISOString().substr(11,5)
150+
return m + ' ' + d + ', ' + (needYear ? y: '' ) + ' ' + date.toTimeString().substr(0, 5)
151151
},
152152
toDateStrShort(date) {
153153
var d = "" + date.getDate();

0 commit comments

Comments
 (0)