-
Notifications
You must be signed in to change notification settings - Fork 315
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
helper-cli: Add a command to generate a flat analyzer result #7305
helper-cli: Add a command to generate a flat analyzer result #7305
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #7305 +/- ##
============================================
+ Coverage 60.93% 68.01% +7.07%
- Complexity 1968 2023 +55
============================================
Files 338 339 +1
Lines 16623 16719 +96
Branches 2363 2371 +8
============================================
+ Hits 10129 11371 +1242
+ Misses 5516 4363 -1153
- Partials 978 985 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
37529d0
to
9084ad9
Compare
Typo in "fullfil", should be "fulfill". In general this sentence is a bit cryptic. Please be transparent about what the "underlying need" is and document it in the commit message. |
I want to start by saying that I agree that writing / generating SPDX files as a substitute for a lack of supported definition files for ORT is cumbersome, mostly because SPDX is such a terrible format IMO. Maybe we should have instead used AboutCode Data or an ORT-specific "fake definition file" format that's easier to use than writing whole analyzer result files from hand. That said, I believe this goal of this PR should be implemented differently: As a company-internal package manager plugin that uses your |
|
9084ad9
to
dfd5531
Compare
Mostly because of the "I believe it is quicker to develop" rationale you mentioned: Doing this as a company-internal package manager plugin (which is something e.g. Bosch has done, too) allows you to fulfill your custom needs quicker without the need for justifications during a review process. And you still keep the option to open-source it later on.
Hard to say for the long term if more features / generalizations get added, but in its current shape it indeed looks like a very specific solution that probably no one except EPAM is interested in. |
I think we've added "experimental" things to ORT / helper-cli already before this PR. |
Right, but this is not about the level of "experimentality", but about where the code fits, whatever the maturity is. And to me a dedicated package manager so clearly is a better fit (if I'm getting the use-case right), that personally I'd draw a line here. Otherwise Bosch, Porsche and others could have contributed their plugins also as helper-cli commands (but we've turned them down). |
Frank forgot to mention we also want to use this new helper functionality to make it more easier to implement org-wide inbound FOSS scanning or pre-scanning. Org-wide inbound FOSS scanning is something we started working whilst at HERE, the idea is to scan a FOSS package the moment it's introduced into the organization. Scenario: Developer does dependencies update in his/her SW project -> packages are being fetched from internal package registry (JFrog Artifactory) -> Artifactory does not have version so retrieves package from public package registry (Maven Central, npmjs.com) and at the same time trigger inbound FOSS scan for each new version via REST API providing package url and VCS url -> inbound FOSS scan executes helper cli command to generate analyzer file defined in this PR -> Generated analyzer result is used to execute ORT scan with ScanCode -> Scan results are added to defined ORT scan storage -> when developer create pull/merge request ORT scan is done and new version of dependency is already scanned -> scan is quick resulting in better user experience and engineer productivity. If new version or package is not OK by ORT policy rules than one can configure Artifactory to block download pointing to the ORT report for details. Similarly one can also implement pre-scanning - from Artifactory usage stats one can deduct most used FOSS package and then logic can be implement to trigger inbound FOSS ORT scan the moment package popular within the org release a new version. |
How's the required |
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
That workflow makes sense to me, we have used it at Bosch as well, for example to implement and test snippet reporter related changes internally before contributing them upstream. This provides a lot of freedom for experiments (because no code reviews are required, for example) and makes it easier to reach a mature state that is worth contributing.
Overall I am not very happy with the state of the helper-cli, because also experimental commands still have to be maintained by the community, and because there are almost no tests. Adding more experiments doesn't improve the situation. Also, I have no idea how many of the commands are still used by anyone or if we maintain them just for the sake of it.
At Bosch we have a very strong requirement for an alternative to the SPDX analyzer, because it makes some very unintuitive assumptions, it feels like 90% of the SPDX that has to be written is boilerplate, and it also does not support all ORT features. We have that topic on our Agenda for later this year, I would appreciate if we could discuss it in a community meeting after the summer break to collect requirements. |
|
I needed something quick in place to help during the next couple of weeks. I understand you guys don't want that, I'll just turn the PR into a draft and keep the branch around for while. |
dfd5531
to
0243449
Compare
1209e92
to
3cf2d2a
Compare
28dae09
to
5c9c77b
Compare
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateFlatAnalyzerResultCommand.kt
Outdated
Show resolved
Hide resolved
e5317f3
to
956f08b
Compare
b253e95
to
2452324
Compare
I've added a test which tests end to end through helper main, which illustrates the input format (and the expected output). |
helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt
Fixed
Show fixed
Hide fixed
helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt
Fixed
Show fixed
Hide fixed
Please note the detekt issues (and rebase to get rid of an unrelated test failure). |
36b52aa
to
6e340da
Compare
@@ -0,0 +1,23 @@ | |||
--- | |||
name: "Example project name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice to have this example now as part of the tests, thank you! This makes some stuff immediately visible to me that I wouldn't have noticed otherwise.
vcs_revision: "0000000000000000000000000000000000000000" | ||
vcs_path: "vcs-path/dependency-one" | ||
source_artifact_url: "https://example.org/example-dependency-one.zip" | ||
is_excluded: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting: We usually do not support the exclusion of a dependency. I need to look further down to see how this is implemented then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one scope for excluded dependencies and another for non-excluded ones.
vcs_path: "vcs-path/dependency-one" | ||
source_artifact_url: "https://example.org/example-dependency-one.zip" | ||
is_excluded: true | ||
is_dynamically_linked: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a chance that we might want to support sub-projects as dependencies? If so, I'd prefer this to be a regular PackageLinkage
enum value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command targets the use case of doing a quick (as possible) scan and clearance for an arbitrary set of packages. In that use case it is unneeded. I also do not foresee to have subprojects.
From our discussion in the developer meeting, what I understood was, (from @mnonnenmacher) there is need for an analyzer which is a bit simpler than SPDX.
And that he preferred to have my simple use case be a helper-cli command, so that this simple use case would not conflict with @mnonnenmacher analyzer use case. So, given that I prefer we keep this helper-command to a minimum and add the more complex cases (like sub projects) to @mnonnenmacher 's analyzer use case if it fits there?!
helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateAnalyzerResultFromPackageListCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateAnalyzerResultFromPackageListCommand.kt
Outdated
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateAnalyzerResultFromPackageListCommand.kt
Outdated
Show resolved
Hide resolved
6e340da
to
6c5fa55
Compare
6c5fa55
to
995bdfe
Compare
helper-cli/src/funTest/assets/create-analyzer-result-from-pkg-list-expected-output.yml
Show resolved
Hide resolved
helper-cli/src/main/kotlin/commands/CreateAnalyzerResultFromPackageListCommand.kt
Outdated
Show resolved
Hide resolved
995bdfe
to
c05897c
Compare
The command defines a data model called `PackageList` which is read as input using any of the known file extensions. It outputs an analyzer result with a single project containing the provided dependencies as a flat list. When a project does not use a package manager, currently the only way of scanning it with ORT is to craft SPDX files and running the analyzer against them. This command tries to provide a minimalistic alternative to fulfill the need to scan any project which does not use any package manager (supported by ORT). The package metadata holds attributes which are usually relevant for license clearance, namely the excluded state and the type of linkage. So, it can be useful to do license clearance for arbitrary sets of packages. This is for now limited to detected license clearance, as providing other attributes like e.g. the declared licenses is not (yet) implemented. Signed-off-by: Frank Viernau <frank_viernau@epam.com>
As the analyzer is responsible for adding all package curations from all configurated providers to the resolved configuration in the ORT file, do so as well when generating the analyzer result from a package list file. This allows to use the standard package curation workflow with `CreateAnalyzerResultFromPackageListCommand`. Signed-off-by: Frank Viernau <frank_viernau@epam.com>
c05897c
to
3f8030f
Compare
The command defines a data model called
SimpleDefinitionFile
which isread as input using any of the known file extensions. It outputs an
analyzer result with a single project containing the provided
dependencies as a flat list.
When a project does not use a package manager, currently the only way of
scanning it with ORT is to craft SPDX files and running the analyzer
against them. This command tries to provide a minimalistic alternative
to fullfil the requirements of the underlying need.
Note: This is a first experimental version. Furthermore,
VcsInfo
is deliberately not used, in order to: