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

Assign a single meta at puzzle creation time #736

Merged
merged 7 commits into from
Jan 9, 2024
Merged

Conversation

maximized
Copy link
Contributor

No description provided.

@maximized maximized marked this pull request as draft January 7, 2024 18:36
@maximized
Copy link
Contributor Author

image image image

@maximized maximized requested review from pcvera and asdfryan January 7, 2024 19:00
@maximized
Copy link
Contributor Author

The dropdown for meta options are also subject to #672

@maximized maximized marked this pull request as ready for review January 7, 2024 21:12
@maximized maximized linked an issue Jan 7, 2024 that may be closed by this pull request
const [name, setName] = React.useState("");
const [url, setUrl] = React.useState("");
const [assignedMeta, setAssignedMeta] = React.useState("none");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with using a falsy value for this?

Copy link
Contributor Author

@maximized maximized Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing. I'll change this value and the default option value to ""

@@ -16,8 +16,8 @@
"cookies"
],
"host_permissions": [
"0.0.0.0:*",
"http://localhost:*/*",
"http://*:*/*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels kind of sketchy, was this just to include 127.0.0.1 or was there more? I guess it's ok as a temporary hack if we need to

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would this potentially get flagged during the Chrome Extension store review?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgossiaux, didn't you say you use 0.0.0.0?

@akirabaruah I actually already included this in the most recent extension upload and it was accepted. However, maybe this is why it took longer.

https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns has Chrome's suggestions. We can include just http://localhost/*, http://127.0.0.1/*, and http://0.0.0.0/*. Their documentation also suggests:

You can also use http://*:*/* to match localhost, IP addresses, and any port.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for the clarifications. SGTM.

I guess we want the *s because we want to run this extension on any website, i.e. arbitrary puzzle pages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I'm not authorizing using OAuth. I'm instead reading the csrftoken from the website's cookie. This is the list of URLs whose cookies I can read from. The asterisks are needed for folks various ports if you want to test it locally.

The access to read any website's title and URL is from the permissions's activeTab

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgossiaux, didn't you say you use 0.0.0.0?

Yeah I do, I was wondering why you changed to the *:*/* wildcard pattern since it looked like the only missing local development host was 127.0.0.1. I think *:*/* could match any random site, right? I don't think we want to ask people to give us permissions to read their cookies on the whole web if we can avoid it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgossiaux I thought *:*/* would match anything with a colon but after testing apparently not. I changed it to "http://127.0.0.1/*" in #737

Copy link
Contributor

@akirabaruah akirabaruah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change LGTM overall modulo @rgossiaux's comments.

<Form.Label>Assigned Meta</Form.Label>
<Form.Control
as="select"
value={assignedMeta}
Copy link
Contributor

@akirabaruah akirabaruah Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a falsy value like null (@rgossiaux's comment above), you can probably change this to value={assignedMeta ?? "none"}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just change both to "".

@@ -16,8 +16,8 @@
"cookies"
],
"host_permissions": [
"0.0.0.0:*",
"http://localhost:*/*",
"http://*:*/*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would this potentially get flagged during the Chrome Extension store review?

meta = get_object_or_404(
Puzzle, name=request.data["assigned_meta"], hunt=puzzle.hunt
)
puzzle.metas.add(meta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a unit test for this? (Can be in a separate PR if we want to expedite this one)

Copy link
Contributor Author

@maximized maximized Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll add a unit test to this PR

Copy link
Contributor

@akirabaruah akirabaruah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with pending changes.

@@ -16,8 +16,8 @@
"cookies"
],
"host_permissions": [
"0.0.0.0:*",
"http://localhost:*/*",
"http://*:*/*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for the clarifications. SGTM.

I guess we want the *s because we want to run this extension on any website, i.e. arbitrary puzzle pages?

@maximized maximized merged commit e77c31a into main Jan 9, 2024
2 checks passed
@maximized maximized deleted the max_set_meta_on_upload branch January 9, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Meta and Tag Assignment in "Add Puzzle" dialog
3 participants