Skip to content

Remove WebPurify check for Play Lab when fetching source file#65468

Merged
fisher-alice merged 2 commits into
stagingfrom
alice/fix-playlab-bug
Apr 24, 2025
Merged

Remove WebPurify check for Play Lab when fetching source file#65468
fisher-alice merged 2 commits into
stagingfrom
alice/fix-playlab-bug

Conversation

@fisher-alice

@fisher-alice fisher-alice commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

This PR removes the WebPurify check for Play Lab projects when fetching the project source file and is a follow-up to #65397 which removed the profanity/privacy check for Play Lab projects on the frontend.

In #65397, I removed the WebPurify filter check for Play Lab projects on project or project-backed level load. However, I did not catch the need to update the backend because I used an account with project validator permission when testing locally.

When fetching the project source file for a project that contains content that would be flagged by WebPurify, 404 is returned if can_view_profane_or_pii_assets? returns false, i.e., you are not the owner nor admin nor have project validator permission. Thus, you get the "This version of this project cannot be found or is no longer available" alert.

Screenshot 2025-04-24 at 8 54 00 AM

This PR makes minimal updates so that we can unblock users in a timely manner. See Zendesk ticket.

However, follow-up is needed. There are a couple pathways moving forward:

  1. Continue to not filter Play Lab projects or any project source using WebPurify -> On backend, deprecate endpoints, remove code/tests not used anymore. On frontend, clean up code including showProjectAdmin in Extra Links. (This is a medium-sized task - branch starting the clean-up process.) - Note that we do have a report abuse system and projects can be blocked by abuse score or project validators. Also, users can no longer self-publish projects to a public gallery as we now host a curated featured project gallery.
  2. Refactor find_share_failure, removing block ids and checking only user-generated text. Re-institute checking Play Lab projects, but also consider checking other project types such as Sprite Lab. (This is a large-sized task.)

Filtering of Play Lab projects was implemented before Sprite Lab existed. In should_filter_program, the program must be from Play Lab and include user-entered-text indicators before find_failure is called.

def self.find_share_failure(program, locale, exceptions: false)
return nil unless should_filter_program(program)
xml_tag_regexp = /<[^>]*>/
program_tags_removed = program.gsub(xml_tag_regexp, "\n")
find_failure(program_tags_removed, locale, exceptions: exceptions)
end
def self.should_filter_program(program)
Gatekeeper.allows('webpurify', default: true) &&
program =~ /#{PLAYLAB_APP_INDICATOR}/o &&
program =~ /(#{USER_ENTERED_TEXT_INDICATORS.join('|')})/
end

When this filter was instituted, Play Lab allowed free-form user text while other project types geared for elementary-age students (such as Artist or Flappy) did not. App Lab and Game Lab allows free-form text, but is restricted to students age 13 and older.

Not filtering Sprite Lab projects while filtering Play Lab projects does seem inconsistent at this point so product recently confirmed that Play Lab should follow the same pattern as Sprite Lab and not be more strict than other labs. However, Mike H brought up pathway option 2 above (filter both Play Lab and Sprite Lab projects after a refactor) during a recent check-in meeting. I'll bring this topic up during a team meeting.

Before update

Screencast video of a Play Lab project that contains a flagged word. A non-owner user opens the project and cannot see project content. However, the current workaround to view project is to remix the project (append '/remix' to end of project URL).

before-update.mov

Screenshot of error in Network tab:

Screenshot 2025-04-24 at 7 33 53 AM

After update

Now a non-owner user and a signed-out user can view a Play Lab project that contains content that would be flagged by WebPurify.

after-update.mov

Warning!!

The AP CSP Create Performance Task is in progress. The most critical dates are from April 3 - April 30, 2025. Please consider any risk introduced by this PR that could affect our students taking AP CSP. Code.org students taking AP CSP primarily use App Lab for their Create Task, however a small percent use Game Lab. Carefully consider whether your change has any risk of alterering, changing, or breaking anything in these two labs. Even small changes, such as a different button color, are considered significant during this time period. Reach out to the Student Learning team or Curriculum team for more details.

Links

Testing story

I tested locally using different types of accounts: student, teacher (without project validator permission), and also as a signed-out user.

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@fisher-alice fisher-alice changed the title Remove WebPurify check for Play Lab when getting source file Remove WebPurify check for Play Lab when fetching source file Apr 24, 2025
@fisher-alice fisher-alice marked this pull request as ready for review April 24, 2025 14:45
@fisher-alice fisher-alice requested a review from a team April 24, 2025 14:46
metadata = result[:metadata]
abuse_score = [metadata['abuse_score'].to_i, metadata['abuse-score'].to_i].max
not_found if abuse_score >= SharedConstants::ABUSE_CONSTANTS.ABUSE_THRESHOLD && !can_view_abusive_assets?(encrypted_channel_id)
not_found if profanity_privacy_violation?(filename, result[:body]) && !can_view_profane_or_pii_assets?(encrypted_channel_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this mean we aren't checking for profanity at all?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's correct. profanity_privacy_violation currently only checks Play Lab project sources (no other project sources are filtered), and we are removing this check.

@molly-moen molly-moen Apr 24, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh gotcha! Could we also update or remove that function (should it always return false now?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By that function I mean should_filter_program

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should. But I am proposing to do so in a follow-up PR because there are other places it is called that other teams may be impacted. See comment in investigation PR: https://github.com/code-dot-org/code-dot-org/pull/65463/files#r2056956932

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We switched to just find_failure here: #65630

@fisher-alice fisher-alice requested a review from molly-moen April 24, 2025 16:00
@fisher-alice fisher-alice merged commit 3220857 into staging Apr 24, 2025
@fisher-alice fisher-alice deleted the alice/fix-playlab-bug branch April 24, 2025 20:51
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.

3 participants