Fix prettier issues, and JSON error in main
This commit is contained in:
+5
-18
@@ -634,7 +634,7 @@ function run() {
|
||||
licenseExclusions: config.allow_dependencies_licenses
|
||||
});
|
||||
const scorecard = yield (0, scorecard_1.getScorecardLevels)(filteredChanges);
|
||||
core.debug(`Scorecard: ${JSON.stringify(scorecard)}`);
|
||||
core.debug(`Scorecard: scorecard}`);
|
||||
core.debug(`Filtered Changes: ${JSON.stringify(filteredChanges)}`);
|
||||
core.debug(`Config Deny Packages: ${JSON.stringify(config)}`);
|
||||
const deniedChanges = yield (0, deny_1.getDeniedChanges)(filteredChanges, config.deny_packages, config.deny_groups);
|
||||
@@ -975,28 +975,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getScorecardLevels = void 0;
|
||||
const schemas_1 = __nccwpck_require__(8774);
|
||||
const packageurl_js_1 = __nccwpck_require__(8915);
|
||||
/**
|
||||
* Loops through a list of changes, filtering and returning the
|
||||
* ones that don't conform to the licenses allow/deny lists.
|
||||
* It will also filter out the changes which are defined in the licenseExclusions list.
|
||||
*
|
||||
* Keep in mind that we don't let users specify both an allow and a deny
|
||||
* list in their config files, so this code works under the assumption that
|
||||
* one of the two list parameters will be empty. If both lists are provided,
|
||||
* we will ignore the deny list.
|
||||
* @param {Change[]} changes The list of changes to filter.
|
||||
* @param { { allow?: string[], deny?: string[], licenseExclusions?: string[]}} licenses An object with `allow`/`deny`/`licenseExclusions` keys, each containing a list of licenses.
|
||||
* @returns {Promise<{Object.<string, Array.<Change>>}} A promise to a Record Object. The keys are strings, unlicensed, unresolved and forbidden. The values are a list of changes
|
||||
*/
|
||||
function getScorecardLevels(changes) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
changes.forEach((change) => {
|
||||
for (const change of changes) {
|
||||
const purl = packageurl_js_1.PackageURL.fromString(change.package_url);
|
||||
const ecosystem = purl.type;
|
||||
const packageName = purl.name;
|
||||
const version = purl.version;
|
||||
return getDepsDevData(ecosystem, packageName, String(version));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getScorecardLevels = getScorecardLevels;
|
||||
@@ -1009,9 +996,9 @@ function getDepsDevData(ecosystem, packageName, version) {
|
||||
const data = yield response.json();
|
||||
//Get the related projects
|
||||
const projects = data.relatedProjects;
|
||||
projects.forEach((project) => {
|
||||
for (const project of projects) {
|
||||
return getDepsDevProjectData(project.projectKey);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function getDepsDevProjectData(projectKey) {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -111,7 +111,7 @@ async function run(): Promise<void> {
|
||||
)
|
||||
|
||||
const scorecard = await getScorecardLevels(filteredChanges)
|
||||
core.debug(`Scorecard: ${JSON.stringify(scorecard)}`)
|
||||
core.debug(`Scorecard: scorecard}`)
|
||||
|
||||
core.debug(`Filtered Changes: ${JSON.stringify(filteredChanges)}`)
|
||||
core.debug(`Config Deny Packages: ${JSON.stringify(config)}`)
|
||||
|
||||
+26
-35
@@ -2,50 +2,41 @@ import {Change, Changes, DepsDevProject, DepsDevProjectSchema} from './schemas'
|
||||
import {isSPDXValid, octokitClient} from './utils'
|
||||
import {PackageURL} from 'packageurl-js'
|
||||
|
||||
/**
|
||||
* Loops through a list of changes, filtering and returning the
|
||||
* ones that don't conform to the licenses allow/deny lists.
|
||||
* It will also filter out the changes which are defined in the licenseExclusions list.
|
||||
*
|
||||
* Keep in mind that we don't let users specify both an allow and a deny
|
||||
* list in their config files, so this code works under the assumption that
|
||||
* one of the two list parameters will be empty. If both lists are provided,
|
||||
* we will ignore the deny list.
|
||||
* @param {Change[]} changes The list of changes to filter.
|
||||
* @param { { allow?: string[], deny?: string[], licenseExclusions?: string[]}} licenses An object with `allow`/`deny`/`licenseExclusions` keys, each containing a list of licenses.
|
||||
* @returns {Promise<{Object.<string, Array.<Change>>}} A promise to a Record Object. The keys are strings, unlicensed, unresolved and forbidden. The values are a list of changes
|
||||
*/
|
||||
|
||||
export async function getScorecardLevels(changes: Change[]): Promise<any> {
|
||||
changes.forEach((change) => {
|
||||
for (const change of changes) {
|
||||
const purl = PackageURL.fromString(change.package_url)
|
||||
const ecosystem = purl.type
|
||||
const packageName = purl.name
|
||||
const version = purl.version
|
||||
return getDepsDevData(ecosystem, packageName, String(version));
|
||||
});
|
||||
return getDepsDevData(ecosystem, packageName, String(version))
|
||||
}
|
||||
}
|
||||
|
||||
const depsDevAPIRoot = 'https://api.deps.dev'
|
||||
|
||||
async function getDepsDevData(ecosystem: String, packageName: String, version: String): Promise<any> {
|
||||
//Query deps.dev GetVersion API
|
||||
const url = `${depsDevAPIRoot}//v3alpha/systems/${ecosystem}/packages/${packageName}/versions/${version}`;
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
//Get the related projects
|
||||
const projects = data.relatedProjects;
|
||||
projects.forEach((project: any) => {
|
||||
return getDepsDevProjectData(project.projectKey);
|
||||
})
|
||||
async function getDepsDevData(
|
||||
ecosystem: String,
|
||||
packageName: String,
|
||||
version: String
|
||||
): Promise<any> {
|
||||
//Query deps.dev GetVersion API
|
||||
const url = `${depsDevAPIRoot}//v3alpha/systems/${ecosystem}/packages/${packageName}/versions/${version}`
|
||||
const response = await fetch(url)
|
||||
const data = await response.json()
|
||||
|
||||
//Get the related projects
|
||||
const projects = data.relatedProjects
|
||||
for (const project of projects) {
|
||||
return getDepsDevProjectData(project.projectKey)
|
||||
}
|
||||
}
|
||||
|
||||
async function getDepsDevProjectData(projectKey: String): Promise<DepsDevProject> {
|
||||
//Query deps.dev GetProject API
|
||||
const url = `${depsDevAPIRoot}//v3alpha/projects/${projectKey}`;
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
return DepsDevProjectSchema.parse(data);
|
||||
async function getDepsDevProjectData(
|
||||
projectKey: String
|
||||
): Promise<DepsDevProject> {
|
||||
//Query deps.dev GetProject API
|
||||
const url = `${depsDevAPIRoot}//v3alpha/projects/${projectKey}`
|
||||
const response = await fetch(url)
|
||||
const data = await response.json()
|
||||
return DepsDevProjectSchema.parse(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user