Skip to content

Conversation

@RichDom2185
Copy link
Member

@RichDom2185 RichDom2185 commented Apr 28, 2023

Description

Cleans up a bunch of code style and quality issues following #2444. Also closes #2459. Do look at commit history for more details.

Turns out the chapter list renderer has been used wrongly this whole time. Items were fetched from exported variables instead of the state. This made it hard to filter. Has since been fixed in 2a3801e.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Checklist

  • I have tested this code
  • I have updated the documentation

This was added during source-academy#2444 for seemingly no reason.
Turns out the chapter list rendered has been used wrongly this whole
time, resulting in an inability to filter. After fixing, a lot of the
conditional rendering can be simplified. This is due to an additional
attribute of SALanguage that was created: the main language that a
sublanguage belongs to.
* Remove commented code
* Remove console.log statement
* Remove useless React fragment
* Use the language enum in the component test
* Remove console.log from test file
* Update snapshot
@RichDom2185 RichDom2185 self-assigned this Apr 28, 2023
@RichDom2185 RichDom2185 requested a review from martin-henz April 28, 2023 22:05
Removed unneeded exports. Also updated the default language selector to
match the abstraction level of the chapter selector in the Playground.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 4835377873

  • 21 of 23 (91.3%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 34.66%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/pages/academy/groundControl/subcomponents/DefaultChapterSelect.tsx 0 2 0.0%
Totals Coverage Status
Change from base Build 4772586399: -0.001%
Covered Lines: 4886
Relevant Lines: 13147

💛 - Coveralls

@RichDom2185
Copy link
Member Author

Before this PR, the existing behaviour was that the following languages:

  • Full JS
  • Full TS
  • HTML
  • All Scheme sublanguages
  • All Python sublangages

Will only show up in the public deployment (and not Source Academy @ X). I've changed the behaviour such that Scheme and Python now also shows up in SA@X deployments.

I believe @zhaojj2209 mentioned something about potential security vulnerabilities/XSS/etc. if we run Full JS/TS/HTML. @zhaojj2209 Can I check if there were any other reasons these languages were set to the public deployment only? I've made sure to maintain that same behaviour for SA@X deployments, as seen in:

...(Constants.playgroundOnly ? [fullJSLanguage, fullTSLanguage, htmlLanguage] : []),

I think enabling Scheme and Python are fine (since they are not running "full" versions of the language). This also "fixes" #2459. What are your thoughts on this @martin-henz ?

@RichDom2185 RichDom2185 requested a review from shenyih0ng April 29, 2023 09:08
@RichDom2185
Copy link
Member Author

@s-kybound can I check on the difference between "Scheme §4" and "Full Scheme"? Would the abovementioned security issue be likely?

@Fidget-Spinner @dylkaw likewise, are there plans for "Full Python"?

@Fidget-Spinner
Copy link
Contributor

No plans for Full Python. A full Python to JS transpiler would be a monumental project.

@s-kybound
Copy link
Member

s-kybound commented Apr 29, 2023

@s-kybound can I check on the difference between "Scheme §4" and "Full Scheme"? Would the abovementioned security issue be likely?

Hi, "Scheme §4" and "Full Scheme" currently have no differences. "Scheme §4" only enables enough of Scheme to complete SICP Chapter 4, while "Full Scheme" will, in future, enable features like macros and first-class continuations. I don't think there will be security issues that could arise from this.

Copy link
Member

@s-kybound s-kybound left a comment

Choose a reason for hiding this comment

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

Looks good to merge

@zhaojj2209
Copy link
Contributor

I believe @zhaojj2209 mentioned something about potential security vulnerabilities/XSS/etc. if we run Full JS/TS/HTML. @zhaojj2209 Can I check if there were any other reasons these languages were set to the public deployment only?

Full JS/TS should not ever be deployed to the NUS version because they make use of eval(), which is a huge security risk. The HTML chapter uses a sandboxed iframe that allows scripts but disables everything else (e.g. cross-origin, popups, etc) so it is relatively safer, but let's still keep it playground-only to be on the safe side.

@RichDom2185 RichDom2185 merged commit 3a43ce3 into source-academy:master Apr 29, 2023
RichDom2185 added a commit to NUS-CS1101S/cadet-frontend that referenced this pull request Jul 15, 2023
* Remove unused dependency

This was added during source-academy#2444 for seemingly no reason.

* Simplify ChapterSelect state update logic

* Fix sublanguage rendering logic and update types

Turns out the chapter list rendered has been used wrongly this whole
time, resulting in an inability to filter. After fixing, a lot of the
conditional rendering can be simplified. This is due to an additional
attribute of SALanguage that was created: the main language that a
sublanguage belongs to.

* Fix Scheme, Python not loading on SA @ X deploys

* Clean up code

* Remove commented code
* Remove console.log statement
* Remove useless React fragment

* Refactor language names to use enum

* Update test and snapshot

* Use the language enum in the component test
* Remove console.log from test file
* Update snapshot

* Migrate playground language state from to use enum

* Remove commented code

* Refactor sublanguage definitions

* Update broken tests

* Fix lint error

* Improve language abstractions

Removed unneeded exports. Also updated the default language selector to
match the abstraction level of the chapter selector in the Playground.
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.

Sublanguage selector goes blank at SA @ X deployment

5 participants