Skip to content

Parser chokes on sobelow_skip comment with trailing content #168

@mikebveil

Description

@mikebveil

Consider a code snippet like this:

# sobelow_skip ["DOS.StringToAtom"] (atoms are a fixed set of table names in the DB schema)
defp get_table_sizes() do
    …
end

The explanation given at the end of the sobelow_skip line will cause parsing to silently fail for the whole file when --skip is used. This is a insidious failure, since it will seem like the comment is working but we're also now ignoring any other findings in the file.

This is because of a regex that runs during parsing to convert these comment lines to @sobelow module attribute statements. The regex replaces the first part of the line but not any trailing content, which becomes garbage at the end of the attribute statement.

I see two ways to fix the regex:

  1. Don't match if sobelow_skip is followed by other content. So we fail to skip the finding but the failure is visible to the user.
  2. Match the whole line and delete any trailing content. This seems the more reasonable way to go, and I've opened a PR (Issue #168: trailing content on an sobelow_ignore line silently breaks parsing #169).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions