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

Internal Templates Loader/Parser caches refactoring #4867

Merged
merged 13 commits into from
Mar 15, 2024
Merged

Conversation

Mzack9999
Copy link
Member

@Mzack9999 Mzack9999 commented Mar 12, 2024

Proposed changes

This PR implements the following changes:

  • Group together (not very elegantly) all templates related code within the pkg/templates/ package to minimize circular import scenarios and redundant logic
  • parsers package has been moved from static to struct and linked to ExecuterOptions, in this way multiple executions will still benefit of the cache, but will be cleared out when the initial object go out of scope. Ref: running nuclei with sdk may have gc problem #4836
  • Structures such asTagFilter are referenced everywhere within the code, and makes it nearly impossible to refactor the internal package tree consistently because Template entity, originally supposed to persist in memory, is tied to runtime execution options. This has been moved and the import loop "hidden" via runtime casting, allowing to reduce Templates to ExecuterOptions scope.

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@Mzack9999 Mzack9999 changed the title bla Internal Templates Loader/Parser caches refactoring Mar 13, 2024
@Mzack9999 Mzack9999 linked an issue Mar 14, 2024 that may be closed by this pull request
@Mzack9999 Mzack9999 marked this pull request as ready for review March 15, 2024 00:14
@Mzack9999 Mzack9999 self-assigned this Mar 15, 2024
Copy link
Member

@tarunKoyalwar tarunKoyalwar left a comment

Choose a reason for hiding this comment

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

lgtm !

pkg/templates/parser.go Outdated Show resolved Hide resolved
@Mzack9999 Mzack9999 mentioned this pull request Mar 15, 2024
4 tasks
@Mzack9999 Mzack9999 merged commit 7d06c97 into dev Mar 15, 2024
12 checks passed
@Mzack9999 Mzack9999 deleted the maint-runner-cache branch March 15, 2024 13:05
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.

Proposal of internal cache refactor
2 participants