Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
92c99e64
Commit
92c99e64
authored
Feb 23, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return not acceptable response on bad flag
parent
8ede0bff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
TasksRepository.java
service/src/main/java/repositories/TasksRepository.java
+3
-9
TasksResource.java
service/src/main/java/resources/TasksResource.java
+6
-3
No files found.
service/src/main/java/repositories/TasksRepository.java
View file @
92c99e64
...
...
@@ -91,21 +91,15 @@ public class TasksRepository implements Repository {
}
}
private
boolean
compareHash
(
String
hash
,
String
username
)
throws
Exception
{
Task
task
=
getUserFlagsHashes
(
username
).
get
(
hash
);
if
(
task
!=
null
)
{
public
boolean
checkFlag
(
String
username
,
String
flagValue
)
throws
Exception
{
Task
task
=
getUserFlagsHashes
(
username
).
get
(
flagValue
);
if
(
task
!=
null
)
{
acceptSolution
(
username
,
task
);
return
true
;
}
return
false
;
}
public
boolean
checkFlag
(
String
username
,
String
flagValue
)
throws
Exception
{
return
compareHash
(
flagValue
,
username
);
//todo: accept solution should be here
}
public
Optional
<
String
>
getUserTaskFlag
(
String
username
,
String
taskId
)
{
//todo: taskId, level, name? discuss
return
getUserFlagsHashes
(
username
).
entrySet
().
stream
()
...
...
service/src/main/java/resources/TasksResource.java
View file @
92c99e64
...
...
@@ -63,9 +63,12 @@ public class TasksResource
//todo: move to solutions resource
@POST
public
boolean
submitSolution
(
@Auth
User
user
,
public
Response
submitSolution
(
@Auth
User
user
,
String
flag
)
throws
Exception
{
return
tasksRepository
.
checkFlag
(
user
.
getName
(),
flag
);
if
(
tasksRepository
.
checkFlag
(
user
.
getName
(),
flag
))
{
return
Response
.
ok
().
build
();
}
return
Response
.
status
(
Response
.
Status
.
NOT_ACCEPTABLE
).
build
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment