Repository: oppia/oppia

Issue:
[BUG]: Replace "whitelist" in code we control
### Describe the bug

We use the term "whitelist" [in a number of places in our code](https://github.com/search?q=repo%3Aoppia%2Foppia+whitelist&type=code), and this term should be placed with a more inclusive and easier-to-understand term (e.g. "allowlist" when the list is of things to allow, "includelist" for lists of things to include, etc.).

### URL of the page where the issue is observed.

_No response_

### Steps To Reproduce

_No response_

### Expected Behavior

_No response_

### Screenshots/Videos

_No response_

### What device are you using?

_No response_

### Operating System

_No response_

### What browsers are you seeing the problem on?

_No response_

### Browser version

_No response_

### Additional context

_No response_

### Tips for developers

Before tackling the bug, please use `git bisect` (see https://git-scm.com/docs/git-bisect) to investigate which PR caused it (you only need to go back as far as commit https://github.com/oppia/oppia/commits/9a334e9). If you find the PR, leave a comment on this issue pointing to it, or just say that it happened before commit 9a334e9 if you could reproduce it there. This will help us fix the issue by reverting the faulty PR.

Also, if this is your first issue, please make sure to follow https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue and https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#setting-things-up before claiming it. Thanks!



Discussion:
Hi @U8NWXD I would like to work on this issue. 

Also, In this case does allowlisted makes more sense?

`// If the user is a guest, has completed this exploration
            // within the context of a collection, and the collection is
            // whitelisted, record their temporary progress.

            if (this.doesCollectionAllowsGuestProgress(
              this.collectionId) && !this.isLoggedIn) {
              this.guestCollectionProgressService.
                recordExplorationCompletedInCollection(
                  this.collectionId, this.explorationId);
            }`
Hello, I had a look at this issue.

I have changed the following files targeting the term whitelist with the most significant alternatives.

![Screenshot 2023-09-29 at 11 01 53 PM](https://github.com/oppia/oppia/assets/108923011/6a693085-e1e3-464c-a38a-43a2ba0663ee)

Since this issue is not assigned to anyone may I..? 
Assigning to @hrshkshri since they were the first to follow [our instructions for good first issues](https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#how-to-tackle-good-first-issues)
Thanks, @U8NWXD I am on it.

Resolving patch:
diff --git a/core/domain/html_cleaner.py b/core/domain/html_cleaner.py
--- a/core/domain/html_cleaner.py
+++ b/core/domain/html_cleaner.py
@@ -41,7 +41,7 @@ class ComponentsDict(TypedDict):
 
 def filter_a(tag: str, name: str, value: str) -> bool:
     """Returns whether the described attribute of a tag should be
-    whitelisted.
+    allowed.
 
     Args:
         tag: str. The name of the tag passed.
@@ -49,7 +49,7 @@ def filter_a(tag: str, name: str, value: str) -> bool:
         value: str. The value of the attribute.
 
     Returns:
-        bool. Whether the given attribute should be whitelisted.
+        bool. Whether the given attribute should be allowed.
 
     Raises:
         Exception. The 'tag' is not as expected.
@@ -67,7 +67,7 @@ def filter_a(tag: str, name: str, value: str) -> bool:
     return False
 
 
-ATTRS_WHITELIST: Final = {
+ATTRS_ALLOWLIST: Final = {
     'a': filter_a,
     'b': [],
     'blockquote': [],
@@ -108,7 +108,7 @@ def clean(user_submitted_html: str) -> str:
     oppia_custom_tags = (
         rte_component_registry.Registry.get_tag_list_with_attrs())
 
-    core_tags = ATTRS_WHITELIST.copy()
+    core_tags = ATTRS_ALLOWLIST.copy()
     core_tags.update(oppia_custom_tags)
     tag_names = list(core_tags.keys())
 
diff --git a/core/domain/state_domain.py b/core/domain/state_domain.py
--- a/core/domain/state_domain.py
+++ b/core/domain/state_domain.py
@@ -896,7 +896,7 @@ def is_rte_content_supported_on_android(
 
         Args:
             require_valid_component_names: function. Function to check
-                whether the RTE tags in the html string are whitelisted.
+                whether the RTE tags in the html string are allowed.
 
         Returns:
             bool. Whether the RTE content is valid.
@@ -3773,14 +3773,14 @@ def is_rte_content_supported_on_android(self) -> bool:
             bool. Whether the RTE components in the state is valid.
         """
         def require_valid_component_names(html: str) -> bool:
-            """Checks if the provided html string contains only whitelisted
+            """Checks if the provided html string contains only allowed
             RTE tags.
 
             Args:
                 html: str. The html string.
 
             Returns:
-                bool. Whether all RTE tags in the html are whitelisted.
+                bool. Whether all RTE tags in the html are allowed.
             """
             component_name_prefix = 'oppia-noninteractive-'
             component_names = set(


Test patch:
diff --git a/core/controllers/collection_editor_test.py b/core/controllers/collection_editor_test.py
--- a/core/controllers/collection_editor_test.py
+++ b/core/controllers/collection_editor_test.py
@@ -77,8 +77,8 @@ def setUp(self) -> None:
 
     def test_access_collection_editor_page(self) -> None:
         """Test access to editor pages for the sample collection."""
-        whitelisted_usernames = [self.EDITOR_USERNAME]
-        self.set_collection_editors(whitelisted_usernames)
+        allowed_usernames = [self.EDITOR_USERNAME]
+        self.set_collection_editors(allowed_usernames)
 
         # Check that it is possible to access a page.
         self.get_json(
@@ -87,13 +87,13 @@ def test_access_collection_editor_page(self) -> None:
                 self.COLLECTION_ID))
 
         # Check that non-editors cannot access the editor page. This is due
-        # to them not being whitelisted.
+        # to them not being allowed.
         self.get_html_response(
             '%s/%s' % (
                 feconf.COLLECTION_EDITOR_URL_PREFIX,
                 self.COLLECTION_ID), expected_status_int=302)
 
-        # Check that whitelisted users can access and edit in the editor page.
+        # Check that allowed users can access and edit in the editor page.
         self.login(self.EDITOR_EMAIL)
         self.get_html_response(
             '%s/%s' % (
@@ -106,17 +106,17 @@ def test_access_collection_editor_page(self) -> None:
         self.logout()
 
     def test_editable_collection_handler_get(self) -> None:
-        whitelisted_usernames = [self.EDITOR_USERNAME]
-        self.set_collection_editors(whitelisted_usernames)
+        allowed_usernames = [self.EDITOR_USERNAME]
+        self.set_collection_editors(allowed_usernames)
 
         # Check that non-editors cannot access the editor data handler.
-        # This is due to them not being whitelisted.
+        # This is due to them not being allowed.
         self.get_json(
             '%s/%s' % (
                 feconf.COLLECTION_EDITOR_DATA_URL_PREFIX,
                 self.COLLECTION_ID), expected_status_int=401)
 
-        # Check that whitelisted users can access the data
+        # Check that allowed users can access the data
         # from the editable_collection_data_handler.
         self.login(self.EDITOR_EMAIL)
 
@@ -130,8 +130,8 @@ def test_editable_collection_handler_get(self) -> None:
     def test_editable_collection_handler_put_with_invalid_payload_version(
         self
     ) -> None:
-        whitelisted_usernames = [self.EDITOR_USERNAME, self.VIEWER_USERNAME]
-        self.set_collection_editors(whitelisted_usernames)
+        allowed_usernames = [self.EDITOR_USERNAME, self.VIEWER_USERNAME]
+        self.set_collection_editors(allowed_usernames)
 
         rights_manager.create_new_collection_rights(
             self.COLLECTION_ID, self.owner_id)
@@ -180,8 +180,8 @@ def test_editable_collection_handler_put_with_invalid_payload_version(
 
     def test_editable_collection_handler_put_cannot_access(self) -> None:
         """Check that non-editors cannot access editable put handler."""
-        whitelisted_usernames = [self.EDITOR_USERNAME, self.VIEWER_USERNAME]
-        self.set_collection_editors(whitelisted_usernames)
+        allowed_usernames = [self.EDITOR_USERNAME, self.VIEWER_USERNAME]
+        self.set_collection_editors(allowed_usernames)
 
         # Assign viewer role to collection.
         rights_manager.create_new_collection_rights(
@@ -208,8 +208,8 @@ def test_editable_collection_handler_put_cannot_access(self) -> None:
 
     def test_editable_collection_handler_put_can_access(self) -> None:
         """Check that editors can access put handler."""
-        whitelisted_usernames = [self.EDITOR_USERNAME, self.VIEWER_USERNAME]
-        self.set_collection_editors(whitelisted_usernames)
+        allowed_usernames = [self.EDITOR_USERNAME, self.VIEWER_USERNAME]
+        self.set_collection_editors(allowed_usernames)
 
         rights_manager.create_new_collection_rights(
             self.COLLECTION_ID, self.owner_id)
@@ -291,8 +291,8 @@ def test_collection_rights_handler(self) -> None:
             rights_domain.ACTIVITY_STATUS_PRIVATE)
 
     def test_get_collection_rights(self) -> None:
-        whitelisted_usernames = [self.OWNER_USERNAME]
-        self.set_collection_editors(whitelisted_usernames)
+        allowed_usernames = [self.OWNER_USERNAME]
+        self.set_collection_editors(allowed_usernames)
 
         self.login(self.OWNER_EMAIL)
 
diff --git a/core/tests/build_sources/assets/constants.js b/core/tests/build_sources/assets/constants.js
--- a/core/tests/build_sources/assets/constants.js
+++ b/core/tests/build_sources/assets/constants.js
@@ -494,7 +494,7 @@ var constants = {
     ]
   }],
 
-  "WHITELISTED_COLLECTION_IDS_FOR_SAVING_GUEST_PROGRESS": [],
+  "ALLOWED_COLLECTION_IDS_FOR_SAVING_GUEST_PROGRESS": [],
 
   "FEEDBACK_SUBJECT_MAX_CHAR_LIMIT": 50,