Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/src/services/nizkctf/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ export default class GitHub {
};
}

async listPullRequests(repoName, username, state) {
async listPullRequests(repoName, state, filter, username = null) {
const status = state === "opened" ? "open" : state;

const { owner, repo } = repoNameHandler(repoName);

const query = `is:pr+repo:${owner}/${repo}+author:${username}+state:${status}`;
const query = filter
? `${filter}+is:pr+repo:${owner}/${repo}+state:${status}`
: `is:pr+repo:${owner}/${repo}+author:${username}+state:${status}`;

const { data } = await this.octokit.search.issuesAndPullRequests({
q: query
Expand Down
1 change: 1 addition & 0 deletions frontend/src/services/nizkctf/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default class GitLab {
};
}
async listPullRequests(projectId, authorUsername, state) {
// TODO implements filter
const response = await this.api.MergeRequests.all({
projectId,
authorUsername,
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/services/nizkctf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,19 @@ export default class NIZKCTF {
const proof = await this._createProof(challenge, keys.privateKey);

const path = getTeamPath(this.team.name);
const message = `Proof: found flag for ${challenge.id}`;
const message = `Proof: found flag for ${challenge.id} - ${path}`;

const list = await this.api.listPullRequests(
this.upstream,
"opened",
`${message}:in:title`
);

if (list.length > 0) {
throw new Error(
"Your team has already sent this flag and it is in the bot's processing queue"
);
}

const newProof = Buffer.from(proof).toString("base64");

Expand Down