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

refactor recursiveScan function #739

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ritish134
Copy link

Breakdown of recursiveScan function: #497

  • Created initializeReport function to initialize and configure the malcontent.Report object.
  • I think Instead of relying on sync.Once to ensure that a match (or miss) is processed only once, I Created setMatchHandling function to do that, basically in this :
    Only the first goroutine to send a result to this channel succeeds due to the buffered capacity of 1.
    matchChan := make(chan matchResult, 1)

context.WithCancel is used to signal all concurrent goroutines to stop further processing once a match is found.

Let me know your thoughts on this @tstromberg

  • the logic for handling OCI image extraction (including the imageURI and ociExtractPath variables) moved into the helper function prepareScanPath.

  • The call to findFilesRecursively is now encapsulated within processPaths. This function is responsible for finding files and managing their subsequent processing.

  • Concurrency Handling logic moved to processWithConcurrency

  • File-specific processing logic into a separate function (processSingleFile)

  • storeFileReport to store individual file reports and
    storeArchiveReports For storing multiple file reports from a sync.Map

Signed-off-by: Ritish Srivastava <121374890+Ritish134@users.noreply.github.com>
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.

1 participant