Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Is there a way only ignore one line code? #146

Open
wszgxa opened this issue Dec 4, 2019 · 3 comments
Open

Is there a way only ignore one line code? #146

wszgxa opened this issue Dec 4, 2019 · 3 comments

Comments

@wszgxa
Copy link

wszgxa commented Dec 4, 2019

Issue Template

Description

Is there a method that we can only ignore one line?
like this

// hawekey-disable-next-line 

I don't want to ignore whole file.

@wszgxa wszgxa changed the title Is there a way only ignore one line file? Is there a way only ignore one line code? Dec 4, 2019
@wszgxa
Copy link
Author

wszgxa commented Dec 27, 2019

Hmm, any response?

@felixhammerl
Copy link
Collaborator

if you run it with the error code, it should allow you to ignore the precise finding. hawkeye can't control what the different tools do, unfortunately, only the findings.

which tools is the one that reports a finding?

@wszgxa
Copy link
Author

wszgxa commented Mar 11, 2020

@felixhammerl Sorry for delay.

It's files-contents module. I have took a look at the code, looks like don't have this functionality.

module.exports = {
  key,
  description: 'Scans for suspicious file contents that are likely to contain secrets',
  enabled: true,
  handles: async () => true,
  run: async fm => fm.languageFiles
    .map(file => ({ file, content: fm.readFileSync(file) }))
    .map(({ file, content }) => patterns.map(pattern => checkFileWithPattern(pattern, file, content)))
    .reduce((flatmap, next) => flatmap.concat(next), [])
    .filter(result => !!result)
    .reduce((results, res) => results[res.level](res), new ModuleResults(key))
}

const checkFileWithPattern = ({ code, level, description, regex }, file, content) => {
  const result = regex.exec(content)
  if (!result) return

  const line = content.split(result[0])[0].split('\n').length
  return { code: `${file}-${code}`, offender: file, description, level, mitigation: `Check line number: ${line}` }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants