Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] Restrict sidecar files #1495

Merged
merged 1 commit into from
Mar 27, 2022
Merged
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
12 changes: 9 additions & 3 deletions cli/server/getDatasetHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ const interpretRequest = (req) => {
if (!query.prefix) throw new Error("'prefix' not defined in request");
const datanameParts = splitPrefixIntoParts(query.prefix);
const info = {parts: datanameParts};
if (query.type && query.type !== "tree") { // "tree" is deprecated
/* query.type is used to indicate which sidecar file should be fetched,
without it we fetch the "main" dataset JSON. See the `Dataset` constructor
in `./src/actions/loadData.js` for which sidecars auspice may try to fetch */
const sidecars = ['tip-frequencies', 'root-sequence', 'measurements'];
if (!query.type || query.type==="tree") {
// note that "tree" is deprecated and unnecessary, so it's ignored
info.dataType = "dataset";
} else if (sidecars.includes(query.type)) {
info.dataType = query.type;
} else {
info.dataType = "dataset";
throw new Error(`Unknown file type '${query.type}' requested.`);
}

return info;
};

Expand Down