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

Initial pre-commit linting #1539

Merged
merged 8 commits into from
May 27, 2024
Merged

Initial pre-commit linting #1539

merged 8 commits into from
May 27, 2024

Conversation

shaidar
Copy link
Contributor

@shaidar shaidar commented Apr 26, 2024

What's this PR do?

This is initial and incomplete work on updating the pre-commit hooks. I was unable to get the prettier plugin to run locally due to package.json dependency issues and think someone more familiar with the project and those packages should take a closer look at resolving those.

@Anas12091101
Copy link
Contributor

I'll be taking a look at the failed checks for this PR

@Anas12091101
Copy link
Contributor

@shaidar the checks are now passing. Do you know why there's no pre-commit check here?

@Anas12091101 Anas12091101 requested a review from asadali145 May 9, 2024 13:40
@arslanashraf7 arslanashraf7 self-requested a review May 13, 2024 13:13
@arslanashraf7 arslanashraf7 self-assigned this May 13, 2024
Comment on lines 68 to 70
# TODO: Update Pylint or Integrate ruff
# - name: Lint
# run: poetry run pylint ./**/*.py
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this since pre-commit should handle this.

- --exclude-files
- ".*_test.js"
- --exclude-files
- "static/js/constants.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should ignore this file. This file is prone to having secrets

static/js/components/NewApplication.js
static/js/components/forms/ProfileFormFields.js
static/js/components/forms/elements/FormError.js
main/templates/background-images.css
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be ignored, But I'm curious why we want to ignore prettier on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps, @shaidar could provide a better answer to this

},
{
"name": "ArtifactoryDetector"
"name": "AWSKeyDetector"
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I was comparing it with xPRO where we have also added "name": "AzureStorageKeyDetector"

@@ -10,4 +10,3 @@ class ApplicationConfig(AppConfig):

def ready(self):
"""Application is ready"""
import applications.signals # pylint:disable=unused-import, unused-variable
Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed to load the signals. We should ignore the error on this line instead. e.g. # noqa: F401

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing this file? If we've moved this step to somewhere else? Could you point me to that location?

Copy link
Contributor

Choose a reason for hiding this comment

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

@shaidar could tell better, the file was removed in one of his commit

Copy link
Contributor

Choose a reason for hiding this comment

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

These scripts checks if someone mistakenly forgot to create a migration file against the changes made in the Django models. It's important that we check this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to add them back

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above comment. Why this file was removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here

}

run_test black --check .
run_test pytest --no-pylint
run_test ./scripts/test/detect_missing_migrations.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

If we put the missing migrations scripts back, we will need to update this as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use travis now, I think we should remove this file.

Copy link

gitguardian bot commented May 21, 2024

⚠️ GitGuardian has uncovered 10 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9430286 Triggered Generic Password 8d4b9e3 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 8d4b9e3 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password e1acbe9 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password e1acbe9 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 0f7f2b9 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 29a9486 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 0f7f2b9 .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 3a90bda .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 3a90bda .github/workflows/ci.yml View secret
9430286 Triggered Generic Password 29a9486 .github/workflows/ci.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@Anas12091101 Anas12091101 force-pushed the sar/pre_commit_linting branch from a2f6573 to 8d4b9e3 Compare May 27, 2024 06:46
Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

Thanks for making all the changes. I smoke tested the application overall and things seem to be working fine.

I just left one last comment, Fee free to merge after that. Don't forget to squash merge.

main/settings.py Outdated
Comment on lines 1023 to 1025
# fmt: off
PASSWORD_RESET_CONFIRM_URL = "password_reset/confirm/{uid}/{token}/" # pragma: allowlist secret
# fmt: on
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you cross-match the same setting with xPRO, We didn't to turn the fmt off/on there. Instead, we used

PASSWORD_RESET_CONFIRM_URL = "password_reset/confirm/{uid}/{token}/"  # noqa: S105 # pragma: allowlist secret

@Anas12091101 Anas12091101 merged commit 8e6c070 into master May 27, 2024
5 checks passed
@Anas12091101 Anas12091101 deleted the sar/pre_commit_linting branch May 27, 2024 13:00
@odlbot odlbot mentioned this pull request May 29, 2024
3 tasks
Anas12091101 added a commit that referenced this pull request Jul 9, 2024
* Initial pre-commit linting

* fix: worked on the suggestions

* fix: fixed some styling issues

* fix: fixed some styling issues

* fix: ignoring git guardian on a line in ci.yml

* revert: ignoring git guardian on a line in ci.yml

* fix: replaced fmt:off with noqa

* fix: black formatting issue

---------

Co-authored-by: Muhammad Anas <[email protected]>
Anas12091101 added a commit that referenced this pull request Jul 9, 2024
* Initial pre-commit linting

* fix: worked on the suggestions

* fix: fixed some styling issues

* fix: fixed some styling issues

* fix: ignoring git guardian on a line in ci.yml

* revert: ignoring git guardian on a line in ci.yml

* fix: replaced fmt:off with noqa

* fix: black formatting issue

---------

Co-authored-by: Muhammad Anas <[email protected]>
Anas12091101 added a commit that referenced this pull request Jul 9, 2024
* Initial pre-commit linting

* fix: worked on the suggestions

* fix: fixed some styling issues

* fix: fixed some styling issues

* fix: ignoring git guardian on a line in ci.yml

* revert: ignoring git guardian on a line in ci.yml

* fix: replaced fmt:off with noqa

* fix: black formatting issue

---------

Co-authored-by: Muhammad Anas <[email protected]>
Anas12091101 added a commit that referenced this pull request Jul 9, 2024
* Initial pre-commit linting

* fix: worked on the suggestions

* fix: fixed some styling issues

* fix: fixed some styling issues

* fix: ignoring git guardian on a line in ci.yml

* revert: ignoring git guardian on a line in ci.yml

* fix: replaced fmt:off with noqa

* fix: black formatting issue

---------

Co-authored-by: Muhammad Anas <[email protected]>
Anas12091101 added a commit that referenced this pull request Jul 15, 2024
* fix(deps): update dependency ramda to ^0.30.0

* fix: manual ramda fixes

* Initial pre-commit linting (#1539)

* Initial pre-commit linting

* fix: worked on the suggestions

* fix: fixed some styling issues

* fix: fixed some styling issues

* fix: ignoring git guardian on a line in ci.yml

* revert: ignoring git guardian on a line in ci.yml

* fix: replaced fmt:off with noqa

* fix: black formatting issue

---------

Co-authored-by: Muhammad Anas <[email protected]>

* Initial pre-commit linting (#1539)

* Initial pre-commit linting

* fix: worked on the suggestions

* fix: fixed some styling issues

* fix: fixed some styling issues

* fix: ignoring git guardian on a line in ci.yml

* revert: ignoring git guardian on a line in ci.yml

* fix: replaced fmt:off with noqa

* fix: black formatting issue

---------

Co-authored-by: Muhammad Anas <[email protected]>

* fix: tests

* fix: formatting issues

* fix: some cleanup

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Asad Ali <[email protected]>
Co-authored-by: Sar <[email protected]>
Co-authored-by: Muhammad Anas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants