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

Tests for pull request #39 Added license handling using Github API when possible #41

Merged
merged 6 commits into from
Nov 26, 2019
Merged

Conversation

coderpatros
Copy link
Member

This builds on pull request #39, thanks @ST-Apps

I'll run a custom build of this against my 200+ repos for a few days to validate this before switching this PR from draft.

@stevespringett this functionality is really awesome and would be great to get out in the wild. So if there is a particular day/time you can spare to push out a new release let me know. Just so I can make sure I've validated the results and updated this PR before then.

@coderpatros
Copy link
Member Author

Running this now and it is looking good :) thanks again @ST-Apps

We have a total of 1660 components being tracked across our projects. So it should flex this pretty well.

@stevespringett
Copy link
Member

Fantastic work @ST-Apps and @coderpatros . When its ready for publication, let me know. I can usually get time to do so within a day or two.

Copy link
Contributor

@ST-Apps ST-Apps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're good to go, just a little change needed on the expressions (what's the plural for "regex"? lol) so that we handle file with different extensions.

Comment on lines 41 to 42
new Regex(@"^https?\:\/\/github\.com\/(?<repositoryId>[^\/]+\/[^\/]+)\/blob\/(?<refSpec>[^\/]+)\/LICENSE(.md)?$"),
new Regex(@"^https?\:\/\/raw\.githubusercontent\.com\/(?<repositoryId>[^\/]+\/[^\/]+)\/(?<refSpec>[^\/]+)\/LICENSE(.md)?$"),
Copy link
Contributor

@ST-Apps ST-Apps Nov 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about this, but I think I encountered some LICENSE.txt files in the past, so we may want to allow some other extensions too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly the documentation states it needs to be LICENSE or LICENSE.md. But it also supports LICENSE.txt. Good pick up @ST-Apps.

But what doesn't work, unfortunately, is the ref parameter. Although it's supported, and the response includes the ref in returned urls, the license object is whatever is in master.

I've raised a support request with github about this. But in the meantime I think we'll just return license information when master is referenced. I think that will cover off almost all cases.

@coderpatros coderpatros marked this pull request as ready for review November 21, 2019 03:06
@coderpatros
Copy link
Member Author

coderpatros commented Nov 21, 2019

@stevespringett this should be good to go with one caveat. The GitHub API has a rate limit of 60 requests per hour for unauthenticated requests. With a token the rate limit is 5000 requests per hour.

Don't know if you want to merge this now and get it out as is. Or wait until I add an option to provide a token (hopefully tonight).

@coderpatros
Copy link
Member Author

coderpatros commented Nov 21, 2019

@stevespringett thinking more about this. It could introduce unpredictable results because of the API throttling. Especially as it is IP based. So a few builds on a build server could quickly use up the unauthenticated quota.

So my question is, do you think it should fail “silently” with console output, fail with an error exit code or be opt in functionality?

I’m leaning toward opt in by providing a token and failing hard if the 5000 limit is hit.

@coderpatros
Copy link
Member Author

Current state of this PR is that if a rate limit is hit BoM generation will fail hard. GitHub license resolution will always be attempted, when applicable, and GitHub API credentials are optional.

This is probably a reasonable approach. New users can try it out ad hoc without generating a GitHub token. And it also prevents "silent" failures from producing inconsistent BoMs.

I'm still running some tests. They normally take about an hour but I suspect they will take a lot longer because of all the extra http calls. But so far this looks pretty solid now.

@coderpatros
Copy link
Member Author

All looks good now @stevespringett if you want to merge this.

@ST-Apps
Copy link
Contributor

ST-Apps commented Nov 21, 2019

Thanks for completing the PR, I wish I had enough time to be more helpful on this.

@coderpatros
Copy link
Member Author

@ST-Apps thanks for your PR. It is very helpful. The only urgency on this one was because I want to start using your new functionality straight away :)

@coderpatros
Copy link
Member Author

@ST-Apps FYI your code is now being used by a government organisation in Australia to help track license compliance and minimise risk for over 200 projects.

@ST-Apps
Copy link
Contributor

ST-Apps commented Nov 22, 2019

That's great!
I work in a team that is heavily focused on Open Source governance and risk management, so it feels good to contribute to such a task :)

@coderpatros
Copy link
Member Author

@stevespringett just bumping this in case it has dropped off your radar :)

Summary of new behaviour...

Current state of this PR is that if a rate limit is hit BoM generation will fail hard. GitHub license resolution will always be attempted, when applicable, and GitHub API credentials are optional.

This is probably a reasonable approach. New users can try it out ad hoc without generating a GitHub token. And it also prevents "silent" failures from producing inconsistent BoMs.

@stevespringett
Copy link
Member

Thanks for the bump. Been out sick. Merging now.

@stevespringett stevespringett merged commit 1c00b64 into CycloneDX:master Nov 26, 2019
@coderpatros coderpatros deleted the issues/30 branch February 5, 2020 13:00
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.

None yet

3 participants