Web: Script Review #2

Open
opened 2024-12-14 06:57:07 +00:00 by Quaternions · 1 comment
Owner

The website needs a script review webpage, only to be used by me personally, so it doesn't need to be fancy.

How does script review work?

Resources

  • Script database stores the actual source of the script, and a hash to find exact matches easily without uploading the entire source again.
  • Script policy database stores what the validation service is supposed to do with each script it finds.
  1. A submission is accepted by a reviewer
  2. The validation service uploads any new scripts to the script database and creates "None" (unreviewed) script policies for each of them.
  3. The Quaternions himself loads the script review webpage, which locates a single unreviewed script using GET /script-policy?Page=1&Limit=1&Policy=0.
  4. The GET /script-policy request returns a ScriptPolicy which is displayed in an editable text box, potentially with Lua syntax highlighting. The page is a form for updating the "None" ScriptPolicy with a different policy. The available policies are:
    pkg/model/policy.go Lines 8 to 12 in 00fdbd9611
    ScriptPolicyNone Policy = 0 // not yet reviewed
    ScriptPolicyAllowed Policy = 1
    ScriptPolicyBlocked Policy = 2
    ScriptPolicyDelete Policy = 3
    ScriptPolicyReplace Policy = 4

    Quaternions selects a policy from the radio menu, and clicks submit. If the policy selection is "Replace", a new Script will need to be created with POST /scripts, before updating the script policy, including ToScriptID.
  5. Updating the script policy:
  • If the policy is "Replace", upload the edited script to POST /scripts which returns the ScriptID of the newly created script. Then, update the policy with POST /script-policy/{ScriptPolicyID} using the ScriptPolicyUpdate openapi data structure. Include the fields "Policy":4 (Replace) and "ToScriptID":ScriptID.
  • If the policy is anything else, no script needs to be uploaded and the only field that need to be included in ScriptPolicyUpdate is Policy.

Bonus points:

  • When "Replace" is selected on the radio menu, a script diff is shown
  • Automatically select "Replace" when the script is edited
  • Disallow submit if the source is changed and "Replace" is not selected
The website needs a script review webpage, only to be used by me personally, so it doesn't need to be fancy. How does script review work? Resources - [Script](https://git.itzana.me/StrafesNET/maps-service/src/commit/2fa3a2d74d74ef9f7edbb79f5f2c1a8e2e2cc709/openapi.yaml#L650) database stores the actual source of the script, and a hash to find exact matches easily without uploading the entire source again. - [Script policy](https://git.itzana.me/StrafesNET/maps-service/src/commit/2fa3a2d74d74ef9f7edbb79f5f2c1a8e2e2cc709/openapi.yaml#L697) database stores what the validation service is supposed to do with each script it finds. 1. A submission is accepted by a reviewer 2. The validation service uploads any new scripts to the script database and creates "None" (unreviewed) script policies for each of them. 3. The Quaternions himself loads the script review webpage, which locates a single unreviewed script using `GET /script-policy?Page=1&Limit=1&Policy=0`. 4. The `GET /script-policy` request returns a [ScriptPolicy](https://git.itzana.me/StrafesNET/maps-service/src/commit/00fdbd9611d73c829e2beb49d97841abc09761fb/openapi.yaml#L730) which is displayed in an editable text box, potentially with Lua syntax highlighting. The page is a form for updating the "None" ScriptPolicy with a different policy. The available policies are: https://git.itzana.me/StrafesNET/maps-service/src/commit/00fdbd9611d73c829e2beb49d97841abc09761fb/pkg/model/policy.go#L8-L12 Quaternions selects a policy from the radio menu, and clicks submit. If the policy selection is "Replace", a new Script will need to be created with `POST /scripts`, before updating the script policy, including ToScriptID. 5. Updating the script policy: - If the policy is "Replace", upload the edited script to `POST /scripts` which returns the ScriptID of the newly created script. Then, update the policy with `POST /script-policy/{ScriptPolicyID}` using the `ScriptPolicyUpdate` openapi data structure. Include the fields `"Policy":4` (Replace) and `"ToScriptID":ScriptID`. - If the policy is anything else, no script needs to be uploaded and the only field that need to be included in `ScriptPolicyUpdate` is `Policy`. Bonus points: - When "Replace" is selected on the radio menu, a script diff is shown - Automatically select "Replace" when the script is edited - Disallow submit if the source is changed and "Replace" is not selected
Member

Some useful packages for the web development process to keep in mind that would help with this,

Syntax highlighting, line numbers, and editing
https://shiki.matsu.io/ (Luau supported)
https://highlightjs.org/
https://microsoft.github.io/monaco-editor/ (Vscode base)

Diff viewer
https://github.com/praneshr/react-diff-viewer

Some useful packages for the web development process to keep in mind that would help with this, **Syntax highlighting, line numbers, and editing** https://shiki.matsu.io/ (Luau supported) https://highlightjs.org/ https://microsoft.github.io/monaco-editor/ (Vscode base) **Diff viewer** https://github.com/praneshr/react-diff-viewer
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: StrafesNET/maps-service#2
No description provided.