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

Add shell parser #2598

Merged
merged 508 commits into from
Jul 27, 2021
Merged

Add shell parser #2598

merged 508 commits into from
Jul 27, 2021

Conversation

pombredanne
Copy link
Member

This is need to parse static package manifest written in bash/sheel such as APKBUILD/PKGBUILD/ebuild/autotools and more (possibly some bitbake too?)

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁

Jorge Bucaran and others added 30 commits November 28, 2014 18:39
… support for it in Javascript, Perl, Python, Ruby and Bash lexers.
If '$' is directly followed by '#' the variable ends right there. This is especially important at the end of a string, as the closing quote would be lexed as part of the variable instead, but was wrong in every other case as well.

Fixed by simply removing the '#?' and letting the following '.' eat it.
2. extract base session lexer ShellSessionBaseLexer.
Add a lexer for the Test Anything Protocol (TAP).
Improve tests.
Use latest pygmars
Use newer parameter-expansion2 (temp advanced patched version)

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
And more and regenerate lexing tests using this new function

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
@pombredanne
Copy link
Member Author

Note: the reason why there are so many commits is that I forked Pygments Bashlexer as a based, keeping the commit history by using git-filter-repo

- Use improved parameter-expansion
- Parse bash arrays
- Simplify lexing and grammar for better readability
- Add new "needed_variables" argument to parsing top-level function to
  limit the set of variables and errors returned to these named in this
  set.
- Improve tracing and variable resolution logic.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
In license detection, we now accept extra expression symbols to use
for license expression detection. This enables the support of custom
SPDX-like license symbols used in some package repos and extra non-SPDX
symbols thta are also commonly used.

- Add a new function "match_spdx_lid.get_spdx_expression()"
- Add new argument "expression_symbols" to all needed functions and
methods.
- Update doc strings accordingly

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This rule is mostly bsd-new and seldom bsd-simplified. We now account
for this with reporting a bsd-new of gpl and a lowered relevance

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
These are exceptions to Copyleft licenses that strictly apply to
OpenSSL and do not turn the licenses in a some Copyleft Limited license.
Therefore I am making these Copyleft instead of Copyleft Limited.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
- Parse APKBUILDs including shell parameter expansion using a shell
  parser and some minimal fixes to ensure we can resolve all key
  package metadata. (in particular sources)
- Refine installed packages data processing to align this with APKBUILD
  parsing
- Add new declared_license detection that can correctly detect licenses
  on all Alpine 3.13 and 3.14 packages. It is composed of expression
  syntax fixes, flexible expression parsing and non-SPDX symbol
  substitution

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This was passing with previsou license updates

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
In the refactoring of 64ad114 a test
was not carried over to ensure we can handle empty license expression
such as "SPDX-License-Identifier: " and not attempt to return an empty
match (with an empty Rule which would fail) if this happens.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
- Apply minor cleanups and formatting
- Refactor EnhancedDebianCopyright to use consistently the method
  debian_copyright.paragraphs() to select parapgraphs.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Use proper quotes rather than backticks

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
These rules were detected incorrectly and theyu are closely related to
other simpler rules. Bumping the coverage helped fix the issues

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This test nee to be updated sometimes when we add new words in the
license index. This is such a case

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This test nee to be updated sometimes when we add new words in the
license index. This is such a case. Added a comment to clarify why this
is happening.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This is better than representation

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Bump pygmars
Remove setuptools, wheel and pip pins

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
@pombredanne
Copy link
Member Author

Things are looking greenish... So I am merging this now!

@pombredanne pombredanne merged commit aa5f923 into develop Jul 27, 2021
@pombredanne pombredanne deleted the shell-parser branch July 27, 2021 21:31
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.