Skip to content

Commit

Permalink
Drop isValid functions of parsers
Browse files Browse the repository at this point in the history
Not in use anymore so we can safely drop it.
  • Loading branch information
JJ-8 committed Aug 10, 2024
1 parent 4356512 commit 3b4c722
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 89 deletions.
13 changes: 0 additions & 13 deletions front/src/ctfnote/parsers/angstrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ const AngstromParser: Parser = {
}
return tasks;
},
isValid(s) {
const data =
parseJson<
Array<{ title: string; category: string; description: string }>
>(s);
return (
Array.isArray(data) &&
data.length > 0 &&
data[0].title != null &&
data[0].category != null &&
data[0].description != null
);
},
};

export default AngstromParser;
5 changes: 0 additions & 5 deletions front/src/ctfnote/parsers/cini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ const CINIParser: Parser = {

return tasks;
},
isValid(s) {
const data = parseJson<Events>(s);
if (data == null) return false;
return data.gamePause !== undefined && data.events !== undefined;
},
};

export default CINIParser;
4 changes: 0 additions & 4 deletions front/src/ctfnote/parsers/ctfd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ const CTFDParser: Parser = {
}
return tasks;
},
isValid(s) {
const data = parseJson<{ data?: unknown }>(s);
return Array.isArray(data?.data);
},
};

export default CTFDParser;
14 changes: 0 additions & 14 deletions front/src/ctfnote/parsers/hitcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ const HitconParser: Parser = {

return tasks;
},
isValid(s) {
const data =
parseJsonStrict<
[{ name: string; category: string; description: string }]
>(s);
if (data == null || data.length < 1) {
return false;
}
return (
data[0].name != null &&
data[0].category != null &&
data[0].description != null
);
},
};

export default HitconParser;
11 changes: 0 additions & 11 deletions front/src/ctfnote/parsers/htb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ const HTBParser: Parser = {
}
return tasks;
},
isValid(s) {
const data = parseJson<{
challenges: Array<{
id: number;
name: string;
description: string;
challenge_category_id: number;
}>;
}>(s);
return Array.isArray(data?.challenges);
},
};

export default HTBParser;
1 change: 0 additions & 1 deletion front/src/ctfnote/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export type ParsedTask = {
export type Parser = {
name: string;
hint: string;
isValid(s: string): boolean;
parse(s: string): ParsedTask[];
};

Expand Down
23 changes: 0 additions & 23 deletions front/src/ctfnote/parsers/justctf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,6 @@ const justCTFParser: Parser = {
}
return tasks;
},
isValid(s) {
const data = parseJson<
[
{
id: number;
name: string;
categories: [string];
difficult: string;
description: string;
points: number;
solvers: number;
}
]
>(s);
return (
data != null &&
data?.length > 0 &&
data[0].id != null &&
data[0].name != null &&
Array.isArray(data[0].categories) &&
data[0].points != null
);
},
};

export default justCTFParser;
12 changes: 0 additions & 12 deletions front/src/ctfnote/parsers/pico.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ const PicoParser: Parser = {
}
return tasks;
},
isValid(s) {
const data = parseJson<{
results: Array<{ name: string; category: { name: string } }>;
}>(s);
return (
data?.results != null &&
Array.isArray(data?.results) &&
data?.results.length > 0 &&
data?.results[0].name != null &&
data?.results[0].category.name != null
);
},
};

export default PicoParser;
6 changes: 0 additions & 6 deletions front/src/ctfnote/parsers/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ const RawParser: Parser = {
}
return tasks;
},
isValid(s) {
return s
.trim()
.split('\n')
.every((s) => /[^|]+\|[^|]+/.exec(s));
},
};

export default RawParser;

0 comments on commit 3b4c722

Please sign in to comment.