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

Resolve CodeQL query alert 56 #5473

Closed
8 of 11 tasks
Tracked by #5159 ...
roslynwythe opened this issue Sep 10, 2023 · 4 comments · Fixed by #6543
Closed
8 of 11 tasks
Tracked by #5159 ...

Resolve CodeQL query alert 56 #5473

roslynwythe opened this issue Sep 10, 2023 · 4 comments · Fixed by #6543
Assignees
Labels
Complexity: Medium Feature: Code Alerts role: back end/devOps Tasks for back-end developers role: front end Tasks for front end developers size: 1pt Can be done in 4-6 hours
Milestone

Comments

@roslynwythe
Copy link
Member

roslynwythe commented Sep 10, 2023

Prerequisite

  1. Be a member of Hack for LA. (There are no fees to join.) If you have not joined yet, please follow the steps on our Getting Started page.
  2. Before you claim or start working on an issue, please make sure you have read our How to Contribute to Hack for LA Guide.

Overview

We need to analyze the query "Use of returnless function" which appears in the CodeQL code alert 56 then either recommend dismissal of the alert or update code to resolve the alert.

Action Items

  • DO NOT DISMISS ANY ALERTS. Dismissal of alerts should be done by dev leads only after review of the recommendation
  • Browse to the links in the following two Action Item and read the contents. Click "See More" to view Recommendations, Examples and References.
  • https://github.com/hackforla/website/security/code-scanning/56
  • In a comment in this issue, add your analysis and recommendations. For each alert, the recommendation can be one of the following: dismiss as test, dismiss as false positive, dismiss as won't fix, or update code.
  • If the recommendation is to update code:
    • create an issue branch and proceed with the code update
    • Use docker to test locally, ensuring that there are no changes to any affected webpage(s)
    • proceed with pull request in the usual manner
  • If the recommendation is to dismiss, describe your reason for dismissal in the comment, then move the issue to Questions/In Review and apply the label ready for dev lead.

For merge team/dev lead

Resources/Instructions

@roslynwythe roslynwythe added Feature Missing This label means that the issue needs to be linked to a precise feature label. role missing size: missing labels Sep 10, 2023
@github-actions

This comment was marked as outdated.

@roslynwythe roslynwythe added Draft Issue is still in the process of being created Complexity: Medium role: back end/devOps Tasks for back-end developers Feature: Code Alerts size: 1pt Can be done in 4-6 hours and removed Feature Missing This label means that the issue needs to be linked to a precise feature label. role missing size: missing labels Sep 10, 2023
@anjolaaoluwa anjolaaoluwa added this to the 02. Security milestone Sep 10, 2023
@roslynwythe roslynwythe added the role: front end Tasks for front end developers label Oct 4, 2023
@roslynwythe roslynwythe changed the title Analysis for CodeQL query "Use of returnless function" Analysis for CodeQL query alerts 56 and 57 Oct 4, 2023
@roslynwythe roslynwythe changed the title Analysis for CodeQL query alerts 56 and 57 Resolve CodeQL query alerts 56 and 57 Oct 8, 2023
@roslynwythe roslynwythe changed the title Resolve CodeQL query alerts 56 and 57 Resolve CodeQL query alerts 56 Mar 20, 2024
@roslynwythe roslynwythe changed the title Resolve CodeQL query alerts 56 Resolve CodeQL query alert 56 Mar 20, 2024
Copy link

Hi @ajb176, thank you for taking up this issue! Hfla appreciates you :)

Do let fellow developers know about your:-
i. Availability: (When are you available to work on the issue/answer questions other programmers might have about your issue?)
ii. ETA: (When do you expect this issue to be completed?)

You're awesome!

P.S. - You may not take up another issue until this issue gets merged (or closed). Thanks again :)

@ajb176
Copy link
Member

ajb176 commented Mar 26, 2024

ETA: One week
Availability: Evenings

@ajb176
Copy link
Member

ajb176 commented Mar 27, 2024

The code should be updated.

Firstly, the same returnless function also occurs in the right-col-content.js file in the same directory, which is importing the same script from ./utility, so this and issue #6479 should be dealt with the same way. Because the issue has already been assigned, I'll just try to coordinate with them.

What seems to be happening is addEventListener is meant to take a function reference with no parameters as an argument, but because a function called InsertEventSchedule with parameters is called, the script immediately runs the function to try to pass its return value as the parameter to addEventListener.

The code is meant to wait until the DOM content is loaded before firing a callback function, but because the callback function isn't formatted correctly, it fires before the condition is necessarily met. In other words, the function tries to populate the event schedule before the DOM content is loaded, despite clearly being designed to wait for the DOM content to load before populating the event schedule.

When I visit HFLA live pages that use the script, they seem to work fine because adding the event schedule just takes more time and the DOM content loads quickly anyway. But the code can be re-factored to fix the CodeQL issue easily by using either an arrow function or an anonymous function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Medium Feature: Code Alerts role: back end/devOps Tasks for back-end developers role: front end Tasks for front end developers size: 1pt Can be done in 4-6 hours
Development

Successfully merging a pull request may close this issue.

4 participants