Skip to content

Commit 43f120d

Browse files
committed
javavulny openapi and more stackhawk examples
1 parent 1478af8 commit 43f120d

File tree

6 files changed

+118
-34
lines changed

6 files changed

+118
-34
lines changed

openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://localhost:9000","description":"Generated server url"}],"paths":{"/api/jwt/items/search/":{"get":{"tags":["jwt-item-controller"],"operationId":"searchAll","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/{text}":{"get":{"tags":["jwt-item-controller"],"operationId":"search","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/auth/signin":{"post":{"tags":["jwt-auth-controller"],"operationId":"signin","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationRequest"}}}},"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/":{"get":{"tags":["token-item-controller"],"operationId":"search_1","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/{text}":{"get":{"tags":["token-item-controller"],"operationId":"search_2","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_3","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/{text}":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_4","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"AuthenticationRequest":{"type":"object","properties":{"username":{"type":"string"},"password":{"type":"string"}}}}}}
1+
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://localhost:9000","description":"Generated server url"}],"paths":{"/api/jwt/auth/signin":{"post":{"tags":["jwt-auth-controller"],"operationId":"signin","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationRequest"}}}},"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/users/search/{text}":{"get":{"tags":["jwt-user-controller"],"operationId":"search","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/users/search/":{"get":{"tags":["jwt-user-controller"],"operationId":"searchAll","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search":{"post":{"tags":["jwt-item-controller"],"operationId":"search_1","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Search"}}}},"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/{text}":{"get":{"tags":["jwt-item-controller"],"operationId":"search_2","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/jwt/items/search/":{"get":{"tags":["jwt-item-controller"],"operationId":"searchAll_1","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_3","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/basic/items/search/{text}":{"get":{"tags":["basic-auth-item-controller"],"operationId":"search_4","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/":{"get":{"tags":["token-item-controller"],"operationId":"search_5","responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/api/token/items/search/{text}":{"get":{"tags":["token-item-controller"],"operationId":"search_6","parameters":[{"name":"text","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"default response","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"AuthenticationRequest":{"type":"object","properties":{"username":{"type":"string"},"password":{"type":"string"}}},"Search":{"type":"object","properties":{"searchText":{"type":"string"}}}}}}

openapi.yaml

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ servers:
66
- url: https://localhost:9000
77
description: Generated server url
88
paths:
9-
/api/jwt/items/search/:
10-
get:
9+
/api/jwt/auth/signin:
10+
post:
1111
tags:
12-
- jwt-item-controller
13-
operationId: searchAll
12+
- jwt-auth-controller
13+
operationId: signin
14+
requestBody:
15+
content:
16+
application/json:
17+
schema:
18+
$ref: '#/components/schemas/AuthenticationRequest'
1419
responses:
1520
200:
1621
description: default response
1722
content:
1823
'*/*':
1924
schema:
2025
type: string
21-
/api/jwt/items/search/{text}:
26+
/api/jwt/users/search/{text}:
2227
get:
2328
tags:
24-
- jwt-item-controller
29+
- jwt-user-controller
2530
operationId: search
2631
parameters:
2732
- name: text
@@ -36,39 +41,39 @@ paths:
3641
'*/*':
3742
schema:
3843
type: string
39-
/api/jwt/auth/signin:
40-
post:
44+
/api/jwt/users/search/:
45+
get:
4146
tags:
42-
- jwt-auth-controller
43-
operationId: signin
44-
requestBody:
45-
content:
46-
application/json:
47-
schema:
48-
$ref: '#/components/schemas/AuthenticationRequest'
47+
- jwt-user-controller
48+
operationId: searchAll
4949
responses:
5050
200:
5151
description: default response
5252
content:
5353
'*/*':
5454
schema:
5555
type: string
56-
/api/token/items/search/:
57-
get:
56+
/api/jwt/items/search:
57+
post:
5858
tags:
59-
- token-item-controller
59+
- jwt-item-controller
6060
operationId: search_1
61+
requestBody:
62+
content:
63+
application/json:
64+
schema:
65+
$ref: '#/components/schemas/Search'
6166
responses:
6267
200:
6368
description: default response
6469
content:
6570
'*/*':
6671
schema:
6772
type: string
68-
/api/token/items/search/{text}:
73+
/api/jwt/items/search/{text}:
6974
get:
7075
tags:
71-
- token-item-controller
76+
- jwt-item-controller
7277
operationId: search_2
7378
parameters:
7479
- name: text
@@ -83,6 +88,18 @@ paths:
8388
'*/*':
8489
schema:
8590
type: string
91+
/api/jwt/items/search/:
92+
get:
93+
tags:
94+
- jwt-item-controller
95+
operationId: searchAll_1
96+
responses:
97+
200:
98+
description: default response
99+
content:
100+
'*/*':
101+
schema:
102+
type: string
86103
/api/basic/items/search/:
87104
get:
88105
tags:
@@ -113,19 +130,32 @@ paths:
113130
'*/*':
114131
schema:
115132
type: string
116-
/log4j:
133+
/api/token/items/search/:
117134
get:
118135
tags:
119-
- jwt-auth-controller
120-
operationId: log4j,
121-
requestBody:
122-
content:
123-
'*/*':
124-
schema:
125-
type: string
136+
- token-item-controller
137+
operationId: search_5
138+
responses:
139+
200:
140+
description: default response
141+
content:
142+
'*/*':
143+
schema:
144+
type: string
145+
/api/token/items/search/{text}:
146+
get:
147+
tags:
148+
- token-item-controller
149+
operationId: search_6
150+
parameters:
151+
- name: text
152+
in: path
153+
required: true
154+
schema:
155+
type: string
126156
responses:
127157
200:
128-
description: default response,
158+
description: default response
129159
content:
130160
'*/*':
131161
schema:
@@ -139,3 +169,8 @@ components:
139169
type: string
140170
password:
141171
type: string
172+
Search:
173+
type: object
174+
properties:
175+
searchText:
176+
type: string

src/main/java/hawk/api/jwt/JwtItemController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package hawk.api.jwt;
22

3+
import hawk.api.SearchResult;
34
import hawk.form.Search;
45
import hawk.service.SearchService;
6+
import lombok.val;
57
import org.springframework.beans.factory.annotation.Autowired;
68
import org.springframework.http.ResponseEntity;
79
import org.springframework.web.bind.annotation.GetMapping;
10+
import org.springframework.web.bind.annotation.Mapping;
811
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.PostMapping;
13+
import org.springframework.web.bind.annotation.RequestBody;
914
import org.springframework.web.bind.annotation.RequestMapping;
1015
import org.springframework.web.bind.annotation.RestController;
1116

@@ -31,4 +36,10 @@ public ResponseEntity search(@PathVariable("text") String text) {
3136
Search search = new Search(text);
3237
return ResponseEntity.ok(searchService.search(search));
3338
}
39+
40+
@PostMapping("/search")
41+
public ResponseEntity search(@RequestBody Search search) {
42+
SearchResult result = new SearchResult(search.getSearchText(), searchService.search(search));
43+
return ResponseEntity.ok(result);
44+
}
3445
}

stackhawk-ajax.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
hawk:
2+
spider:
3+
ajax: true
4+
ajaxBrowser: FIREFOX
5+
config:
6+
- "ajaxSpider.eventWait=20"
7+
- "ajaxSpider.reloadWait=70"
8+
9+

stackhawk-openapi.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
app:
2+
applicationId: ${APP_ID:dacc7d3e-babc-47d2-b040-ab117ab04526}
3+
env: ${APP_ENV:dev-api}
4+
host: ${APP_HOST:https://localhost:9000}
5+
excludePaths:
6+
- "/logout"
7+
antiCsrfParam: "_csrf"
8+
authentication:
9+
loggedInIndicator: "HTTP.*200.*"
10+
loggedOutIndicator: ".*Location:.*/login.*"
11+
usernamePassword:
12+
type: JSON
13+
loginPath: /api/jwt/auth/signin
14+
usernameField: username
15+
passwordField: password
16+
scanUsername: "user"
17+
scanPassword: "password"
18+
tokenAuthorization:
19+
type: HEADER
20+
value: Authorization
21+
tokenType: Bearer
22+
tokenExtraction:
23+
type: TOKEN_PATH
24+
value: "token"
25+
testPath:
26+
path: /api/jwt/items/search/i
27+
success: "HTTP.*200.*"
28+
openApiConf:
29+
# path: /openapi
30+
filePath: openapi.yaml

stackhawk.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
app:
2-
applicationId: ${APP_ID:dacc7d3e-babc-47d2-b040-ab117ab04526}
2+
applicationId: ${APP_ID:30a44281-c5a7-46c9-912d-0f5c6a0f3c69}
33
env: ${APP_ENV:dev}
44
host: ${APP_HOST:https://localhost:9000}
55
excludePaths:
66
- "/logout"
7-
#- "/login-form-multi"
8-
#- "/login-code"
7+
# - "/login-form-multi"
8+
# - "/login-code"
99
antiCsrfParam: "_csrf"
1010
authentication:
1111
loggedInIndicator: "\\QSign Out\\E"
@@ -31,4 +31,3 @@ hawk:
3131
# - "scanner.analyser.redirectEqualsNotFound=false"
3232
# - "scanner.analyser.followRedirect=true"
3333

34-

0 commit comments

Comments
 (0)