JavaScript Java CSS HTML Other
Clone or download
brianmcfeeley and nireeshT Fixed a bug in the github client that improperly handled paged respon…
…ses (#2312)

Github's `Link` header values are URL Encoded. An example:

```
Key: Link
Value: <https://api.github.com/repositories/<some_repo>/commits?sha=refs%2Fheads%2Fmaster&since=2018-06-06T17%3A39Z&page=2>; rel="next", <https://api.github.com/repositories/<some_repo>/commits?sha=refs%2Fheads%2Fmaster&since=2018-06-06T17%3A39Z&page=2>; rel="last"
```

The client as written is incapable of correctly following an encoded link and results in a 404 Not Found error.

I suspect this error is what has been reported here and there already but hasn't been reproduced -- I spent the day spelunking this project's Issue history and noticed several issues similar to what I observed today.

I confirmed this resolution by crafting a small test I could step through in my IDE, that looked like:

```
    @test
    public void breakingScenario() throws MalformedURLException, HygieiaException {

        GitHubRepo repo = new GitHubRepo();
        repo.setRepoUrl("https://github.com/<my organization>/<a high velocity repository>");
        repo.setBranch("refs/heads/master");
        repo.setPersonalAccessToken("<redacted>");

        GitHubSettings settings = new GitHubSettings();
        settings.setErrorThreshold(100);
        settings.setKey("<redacted>");
        GitHubClient client = new DefaultGitHubClient(settings, new RestOperationsSupplier());

        List<Commit> commits = client.getCommits(repo, true, new ArrayList<>());
        assert commits.size() > 0;
    }
```

On master, this test passes for repositories returning no `Link` header, but fails on repositories returning a `Link` header.
I was able to force the test to fail by amending my `GithubSettings` to search a larger trailing window, say 100 days instead of 14,
as this ensured for any reasonably active repository that I'd see paged results.

After applying my decoding change, the test passed for all repositories I tried, and for all date ranges.
Latest commit a052ffa Jul 17, 2018
Permalink
Failed to load latest commit information.
.mvn/wrapper added maven wrapper Dec 11, 2015
UI-protractor-tests UI Protractor Tests Project (#1890) Jan 15, 2018
UI-tests Circumvent docker-maven-plugin (#2039) Mar 21, 2018
UI Revert "Fix for #2246, changing npm url from http to https" (#2252) Jun 18, 2018
api-audit Api audit - SCA metrics fix for 6.7 (#2348) Jul 10, 2018
api CollectorItem refresh (#2356) Jul 13, 2018
certs Centralized entreprise certificate management + addition in Bitbucket… Jun 25, 2018
collectors Fixed a bug in the github client that improperly handled paged respon… Jul 17, 2018
core Adding logic to update incidents with the latest data from hpsm (#2345) Jul 17, 2018
db Docker compose refactor (#1972) Feb 3, 2018
hygieia-jenkins-plugin Update for plugin to store build path instead of name (#2306) Jun 20, 2018
media Jenkins 2.0 support in Hygieia Jenkins plugin (#1055) Jan 3, 2017
test-servers Redirecting README files to gh-pages branch (#1624) Aug 17, 2017
.gitignore Centralized entreprise certificate management + addition in Bitbucket… Jun 25, 2018
.travis.yml Travis build notifications modified (#2256) May 31, 2018
CHANGELOG.md Introduce CHANGELOG to keep track of changes (#1807) Dec 3, 2017
Dockerfile Circumvent docker-maven-plugin (#2039) Mar 21, 2018
Hygieia2.md Redirecting README files to gh-pages branch (#1624) Aug 17, 2017
LICENSE Update LICENSE Feb 19, 2016
MAINTAINERS Modified Maintainers file Sep 21, 2016
README.md Update README.md (#2209) May 16, 2018
Setup.md Redirecting README files to gh-pages branch (#1624) Aug 17, 2017
checkstyle.xml removed gradle Aug 26, 2015
circle.yml Fixed circle.yml for multi module dependencies Jul 23, 2016
docker-compose.override.example.yml Circumvent docker-maven-plugin (#2039) Mar 21, 2018
docker-compose.yml Centralized entreprise certificate management + addition in Bitbucket… Jun 25, 2018
features.md Redirecting README files to gh-pages branch (#1624) Aug 17, 2017
hygieia.json EnvironmentComponentEventListener implementation started Jan 27, 2016
mongosrc.js Jenkins/code quality (#1368) Aug 1, 2017
mvnw added maven wrapper Dec 11, 2015
mvnw.cmd added maven wrapper Dec 11, 2015
pmd.xml tightened pmd rules and refactored code in widgets Dec 4, 2015
pom.xml Configuration option in admin page with collector changes & Rally col… Apr 27, 2018
release.md Redirecting README files to gh-pages branch (#1624) Aug 17, 2017
rev-version.sh fixed version to be greater than the largest released component (vers… Nov 4, 2015
wrap.sh added maven wrapper Dec 11, 2015

README.md