Skip to content

Commit

Permalink
Merge pull request #845 from xexyl/bad-manifest-files
Browse files Browse the repository at this point in the history
  • Loading branch information
lcn2 authored Nov 7, 2023
2 parents 47ac329 + c6d71f3 commit 3d78f65
Show file tree
Hide file tree
Showing 13 changed files with 380 additions and 52 deletions.
24 changes: 24 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Major changes to the IOCCC entry toolkit

## Release 1.0.55 2023-11-07

Add another forbidden file name in submissions: `prog.alt` (prog.alt.c is
allowed).

Modularise the checks for invalid filenames in entries. For instance in
`check_extra_file()` there's no need to check each extra filename and then give
the same error message changing the macro of the filename that's disallowed when
we can just print the string being tested against. The only difference is that
there's one if (with multiple checks) and instead of duplicating the same error
message we just print it once with the string being tested against. Note that
there are two sets of checks: one for extra files being required filenames and
another for disallowed filenames.

Make sure to use the macros for the filenames, not the literal strings (e.g. use
`PROG_FILENAME` not `"prog"`).

Check filenames in alphabetical order (I think :-) .. very tired so maybe missed
one or two).

Note that the function `check_extra_file()` CANNOT be used in every case so it's
not used except in chkentry!


## Release 1.0.54 2023-11-06

The following filenames are no longer allowed in an entry's extra files list:
Expand Down
6 changes: 4 additions & 2 deletions mkiocccentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -3038,8 +3038,10 @@ check_extra_data_files(struct info *infop, char const *entry_dir, char const *cp
not_reached();
}

if (!strcasecmp(args[i], "README.md") || !strcasecmp(args[i], "index.html") || !strcasecmp(args[i], "inventory.html") ||
!strcasecmp(args[i], "prog.orig.c") || !strcasecmp(args[i], "prog.orig") || !strcasecmp(args[i], "prog")) {
if (!strcasecmp(args[i], README_MD_FILENAME) || !strcasecmp(args[i], INDEX_HTML_FILENAME) ||
!strcasecmp(args[i], INVENTORY_HTML_FILENAME) || !strcasecmp(args[i], PROG_FILENAME) ||
!strcasecmp(args[i], PROG_ALT_FILENAME) || !strcasecmp(args[i], PROG_ORIG_FILENAME) ||
!strcasecmp(args[i], PROG_ORIG_C_FILENAME)) {
fpara(stderr,
"",
"An extra file cannot be named any of:",
Expand Down
53 changes: 11 additions & 42 deletions soup/entry_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2879,52 +2879,21 @@ test_extra_file(char const *str)
}

/* verify that extra_file does not match a mandatory filename */
if (strcasecmp(str, INFO_JSON_FILENAME) == 0) {
if (!strcasecmp(str, AUTH_JSON_FILENAME) || !strcasecmp(str, INFO_JSON_FILENAME) ||
!strcasecmp(str, MAKEFILE_FILENAME) || !strcasecmp(str, PROG_C_FILENAME) ||
!strcasecmp(str, REMARKS_FILENAME)) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches a mandatory file %s", INFO_JSON_FILENAME);
return false;
} else if (strcasecmp(str, AUTH_JSON_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches a mandatory file %s", AUTH_JSON_FILENAME);
return false;
} else if (strcasecmp(str, PROG_C_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches a mandatory file %s", PROG_C_FILENAME);
return false;
} else if (strcasecmp(str, MAKEFILE_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches a mandatory file %s", MAKEFILE_FILENAME);
return false;
} else if (strcasecmp(str, REMARKS_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches a mandatory file %s", REMARKS_FILENAME);
"invalid: extra_file matches a mandatory file: <%s>", str);
return false;
}
/* also verify it does not match a disallowed filename */
else if (strcasecmp(str, README_MD_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches invalid filename %s", README_MD_FILENAME);
return false;
} else if (strcasecmp(str, PROG_ORIG_C_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches invalid filename %s", PROG_ORIG_C_FILENAME);
return false;
} else if (strcasecmp(str, PROG_ORIG_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches invalid filename %s", PROG_ORIG_FILENAME);
return false;
} else if (strcasecmp(str, INDEX_HTML_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches invalid filename %s", INDEX_HTML_FILENAME);
return false;
} else if (strcasecmp(str, INVENTORY_HTML_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches invalid filename %s", INVENTORY_HTML_FILENAME);
return false;
} else if (strcasecmp(str, PROG_FILENAME) == 0) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches invalid filename %s", PROG_FILENAME);
return false;
else if (!strcasecmp(str, INDEX_HTML_FILENAME) || !strcasecmp(str, INVENTORY_HTML_FILENAME) ||
!strcasecmp(str, PROG_FILENAME) || !strcasecmp(str, PROG_ALT_FILENAME) ||
!strcasecmp(str, PROG_ORIG_FILENAME) || !strcasecmp(str, PROG_ORIG_C_FILENAME) ||
!strcasecmp(str, README_MD_FILENAME)) {
json_dbg(JSON_DBG_MED, __func__,
"invalid: extra_file matches disallowed filename: <%s>", str);
return false;
}
json_dbg(JSON_DBG_MED, __func__, "extra_file is valid");
return true;
Expand Down
10 changes: 5 additions & 5 deletions soup/entry_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
#define PROG_C_FILENAME "prog.c"
#define REMARKS_FILENAME "remarks.md"
#define MAKEFILE_FILENAME "Makefile"
#define README_MD_FILENAME "README.md"
#define PROG_ORIG_C_FILENAME "prog.orig.c"
#define PROG_FILENAME "prog"
#define PROG_ORIG_FILENAME "prog.orig"
#define INDEX_HTML_FILENAME "index.html"
#define INVENTORY_HTML_FILENAME "inventory.html"

#define PROG_FILENAME "prog"
#define PROG_ALT_FILENAME "prog.alt"
#define PROG_ORIG_FILENAME "prog.orig"
#define PROG_ORIG_C_FILENAME "prog.orig.c"
#define README_MD_FILENAME "README.md"

/*
* IOCCC author information
Expand Down
1 change: 1 addition & 0 deletions test_ioccc/test_JSON/info.json/bad/info.manifest-34.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
{"remarks" : "remarks.md"},
{"extra_file" : "README.md"},
{"extra_file" : "prog.orig.c"},
{"extra_file" : "prog.alt"},
{"extra_file" : "prog.orig"},
{"extra_file" : "prog"},
{"extra_file" : "index.html"},
Expand Down
47 changes: 47 additions & 0 deletions test_ioccc/test_JSON/info.json/bad/info.manifest-README-md.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"IOCCC_info_version" : "1.14 2023-02-04",
"IOCCC_contest" : "IOCCCMOCK",
"IOCCC_year" : 2023,
"mkiocccentry_version" : "1.0.2 2023-11-06",
"iocccsize_version" : "28.13 2023-02-04",
"chkentry_version" : "1.0 2023-02-04",
"fnamchk_version" : "1.0 2023-02-04",
"txzchk_version" : "1.0.2 2023-11-06",
"IOCCC_contest_id" : "12345678-1234-4321-abcd-1234567890ab",
"entry_num" : 0,
"title" : "title-for-entry0",
"abstract" : "abstract for entry #0",
"tarball" : "entry.12345678-1234-4321-abcd-1234567890ab-0.1675547786.txz",
"rule_2a_size" : 0,
"rule_2b_size" : 0,
"empty_override" : true,
"rule_2a_override" : false,
"rule_2a_mismatch" : false,
"rule_2b_override" : false,
"highbit_warning" : false,
"nul_warning" : false,
"trigraph_warning" : false,
"wordbuf_warning" : false,
"ungetc_warning" : false,
"Makefile_override" : false,
"first_rule_is_all" : true,
"found_all_rule" : true,
"found_clean_rule" : true,
"found_clobber_rule" : true,
"found_try_rule" : true,
"test_mode" : false,
"manifest" : [
{"info_JSON" : ".info.json"},
{"auth_JSON" : ".auth.json"},
{"c_src" : "prog.c"},
{"Makefile" : "Makefile"},
{"remarks" : "remarks.md"},
{"extra_file" : "README.md"}
],
"formed_timestamp" : 1675547786,
"formed_timestamp_usec" : 13685,
"timestamp_epoch" : "Thu Jan 01 00:00:00 1970 UTC",
"min_timestamp" : 1675547786,
"formed_UTC" : "Sat Feb 04 21:56:26 2023 UTC"
}
47 changes: 47 additions & 0 deletions test_ioccc/test_JSON/info.json/bad/info.manifest-index-html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"IOCCC_info_version" : "1.14 2023-02-04",
"IOCCC_contest" : "IOCCCMOCK",
"IOCCC_year" : 2023,
"mkiocccentry_version" : "1.0.2 2023-11-06",
"iocccsize_version" : "28.13 2023-02-04",
"chkentry_version" : "1.0 2023-02-04",
"fnamchk_version" : "1.0 2023-02-04",
"txzchk_version" : "1.0.2 2023-11-06",
"IOCCC_contest_id" : "12345678-1234-4321-abcd-1234567890ab",
"entry_num" : 0,
"title" : "title-for-entry0",
"abstract" : "abstract for entry #0",
"tarball" : "entry.12345678-1234-4321-abcd-1234567890ab-0.1675547786.txz",
"rule_2a_size" : 0,
"rule_2b_size" : 0,
"empty_override" : true,
"rule_2a_override" : false,
"rule_2a_mismatch" : false,
"rule_2b_override" : false,
"highbit_warning" : false,
"nul_warning" : false,
"trigraph_warning" : false,
"wordbuf_warning" : false,
"ungetc_warning" : false,
"Makefile_override" : false,
"first_rule_is_all" : true,
"found_all_rule" : true,
"found_clean_rule" : true,
"found_clobber_rule" : true,
"found_try_rule" : true,
"test_mode" : false,
"manifest" : [
{"info_JSON" : ".info.json"},
{"auth_JSON" : ".auth.json"},
{"c_src" : "prog.c"},
{"Makefile" : "Makefile"},
{"remarks" : "remarks.md"},
{"extra_file" : "index.html"}
],
"formed_timestamp" : 1675547786,
"formed_timestamp_usec" : 13685,
"timestamp_epoch" : "Thu Jan 01 00:00:00 1970 UTC",
"min_timestamp" : 1675547786,
"formed_UTC" : "Sat Feb 04 21:56:26 2023 UTC"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"IOCCC_info_version" : "1.14 2023-02-04",
"IOCCC_contest" : "IOCCCMOCK",
"IOCCC_year" : 2023,
"mkiocccentry_version" : "1.0.2 2023-11-06",
"iocccsize_version" : "28.13 2023-02-04",
"chkentry_version" : "1.0 2023-02-04",
"fnamchk_version" : "1.0 2023-02-04",
"txzchk_version" : "1.0.2 2023-11-06",
"IOCCC_contest_id" : "12345678-1234-4321-abcd-1234567890ab",
"entry_num" : 0,
"title" : "title-for-entry0",
"abstract" : "abstract for entry #0",
"tarball" : "entry.12345678-1234-4321-abcd-1234567890ab-0.1675547786.txz",
"rule_2a_size" : 0,
"rule_2b_size" : 0,
"empty_override" : true,
"rule_2a_override" : false,
"rule_2a_mismatch" : false,
"rule_2b_override" : false,
"highbit_warning" : false,
"nul_warning" : false,
"trigraph_warning" : false,
"wordbuf_warning" : false,
"ungetc_warning" : false,
"Makefile_override" : false,
"first_rule_is_all" : true,
"found_all_rule" : true,
"found_clean_rule" : true,
"found_clobber_rule" : true,
"found_try_rule" : true,
"test_mode" : false,
"manifest" : [
{"info_JSON" : ".info.json"},
{"auth_JSON" : ".auth.json"},
{"c_src" : "prog.c"},
{"Makefile" : "Makefile"},
{"remarks" : "remarks.md"},
{"extra_file" : "inventory.html"}
],
"formed_timestamp" : 1675547786,
"formed_timestamp_usec" : 13685,
"timestamp_epoch" : "Thu Jan 01 00:00:00 1970 UTC",
"min_timestamp" : 1675547786,
"formed_UTC" : "Sat Feb 04 21:56:26 2023 UTC"
}
47 changes: 47 additions & 0 deletions test_ioccc/test_JSON/info.json/bad/info.manifest-prog-alt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"IOCCC_info_version" : "1.14 2023-02-04",
"IOCCC_contest" : "IOCCCMOCK",
"IOCCC_year" : 2023,
"mkiocccentry_version" : "1.0.2 2023-11-06",
"iocccsize_version" : "28.13 2023-02-04",
"chkentry_version" : "1.0 2023-02-04",
"fnamchk_version" : "1.0 2023-02-04",
"txzchk_version" : "1.0.2 2023-11-06",
"IOCCC_contest_id" : "12345678-1234-4321-abcd-1234567890ab",
"entry_num" : 0,
"title" : "title-for-entry0",
"abstract" : "abstract for entry #0",
"tarball" : "entry.12345678-1234-4321-abcd-1234567890ab-0.1675547786.txz",
"rule_2a_size" : 0,
"rule_2b_size" : 0,
"empty_override" : true,
"rule_2a_override" : false,
"rule_2a_mismatch" : false,
"rule_2b_override" : false,
"highbit_warning" : false,
"nul_warning" : false,
"trigraph_warning" : false,
"wordbuf_warning" : false,
"ungetc_warning" : false,
"Makefile_override" : false,
"first_rule_is_all" : true,
"found_all_rule" : true,
"found_clean_rule" : true,
"found_clobber_rule" : true,
"found_try_rule" : true,
"test_mode" : false,
"manifest" : [
{"info_JSON" : ".info.json"},
{"auth_JSON" : ".auth.json"},
{"c_src" : "prog.c"},
{"Makefile" : "Makefile"},
{"remarks" : "remarks.md"},
{"extra_file" : "prog.alt"}
],
"formed_timestamp" : 1675547786,
"formed_timestamp_usec" : 13685,
"timestamp_epoch" : "Thu Jan 01 00:00:00 1970 UTC",
"min_timestamp" : 1675547786,
"formed_UTC" : "Sat Feb 04 21:56:26 2023 UTC"
}
48 changes: 48 additions & 0 deletions test_ioccc/test_JSON/info.json/bad/info.manifest-prog-orig-c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
"IOCCC_info_version" : "1.14 2023-02-04",
"IOCCC_contest" : "IOCCCMOCK",
"IOCCC_year" : 2023,
"mkiocccentry_version" : "1.0.2 2023-11-06",
"iocccsize_version" : "28.13 2023-02-04",
"chkentry_version" : "1.0 2023-02-04",
"fnamchk_version" : "1.0 2023-02-04",
"txzchk_version" : "1.0.2 2023-11-06",
"IOCCC_contest_id" : "12345678-1234-4321-abcd-1234567890ab",
"entry_num" : 0,
"title" : "title-for-entry0",
"abstract" : "abstract for entry #0",
"tarball" : "entry.12345678-1234-4321-abcd-1234567890ab-0.1675547786.txz",
"rule_2a_size" : 0,
"rule_2b_size" : 0,
"empty_override" : true,
"rule_2a_override" : false,
"rule_2a_mismatch" : false,
"rule_2b_override" : false,
"highbit_warning" : false,
"nul_warning" : false,
"trigraph_warning" : false,
"wordbuf_warning" : false,
"ungetc_warning" : false,
"Makefile_override" : false,
"first_rule_is_all" : true,
"found_all_rule" : true,
"found_clean_rule" : true,
"found_clobber_rule" : true,
"found_try_rule" : true,
"test_mode" : false,
"manifest" : [
{"info_JSON" : ".info.json"},
{"auth_JSON" : ".auth.json"},
{"c_src" : "prog.c"},
{"Makefile" : "Makefile"},
{"remarks" : "remarks.md"},
{"extra_file" : "README.md"},
{"extra_file" : "prog.orig.c"}
],
"formed_timestamp" : 1675547786,
"formed_timestamp_usec" : 13685,
"timestamp_epoch" : "Thu Jan 01 00:00:00 1970 UTC",
"min_timestamp" : 1675547786,
"formed_UTC" : "Sat Feb 04 21:56:26 2023 UTC"
}
Loading

0 comments on commit 3d78f65

Please sign in to comment.