Skip to content

Commit

Permalink
CodeQL recommendations (#1218)
Browse files Browse the repository at this point in the history
* url parsing based on codeql results

* Update src/drivers/github.js

* debug

* lazy debugging

* bad ternary?

* lazy debugging

* Revert things

This reverts commit df90c98.

This reverts commit f11c8ae.

This reverts commit 39d0a45.

* Cleanup
  • Loading branch information
dacbd authored Oct 8, 2022
1 parent c83044e commit c97e548
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bin/cml/asset/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ exports.handler = async (opts) => {
opts.native = true;
}

const { file, repo, native, asset: path } = opts;
const cml = new CML({ ...opts, repo: native ? repo : 'cml' });
const { file, asset: path } = opts;
const cml = new CML({ ...opts });
const output = await cml.publish({ ...opts, path });

if (!file) console.log(output);
Expand Down
7 changes: 4 additions & 3 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ const inferToken = () => {
const inferDriver = (opts = {}) => {
const { repo } = opts;
if (repo) {
if (repo.includes('github.com')) return GITHUB;
if (repo.includes('gitlab.com')) return GITLAB;
if (/bitbucket\.(com|org)/.test(repo)) return BB;
const url = new URL(repo);
if (url.hostname === 'github.com') return GITHUB;
if (url.hostname === 'gitlab.com') return GITLAB;
if (/bitbucket\.(com|org)/.test(url.hostname)) return BB;
}

if (GITHUB_REPOSITORY) return GITHUB;
Expand Down
5 changes: 2 additions & 3 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ const octokit = (token, repo) => {
onAbuseLimit: throttleHandler
}
};

if (!repo.includes('github.com')) {
const { host, hostname } = new url.URL(repo);
if (hostname !== 'github.com') {
// GitHub Enterprise, use the: repo URL host + '/api/v3' - as baseURL
// as per: https://developer.github.com/enterprise/v3/enterprise-admin/#endpoint-urls
const { host } = new url.URL(repo);
octokitOptions.baseUrl = `https://${host}/api/v3`;
}

Expand Down

0 comments on commit c97e548

Please sign in to comment.