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

Add RPM/Mariner support to service #956

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"bdd",
"--timeout",
"999999",
"--exit",
Expand Down Expand Up @@ -53,4 +53,4 @@
"port": 9230
}
]
}
}
1 change: 1 addition & 0 deletions business/statsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class StatsService {
pypi: () => this._getType('pypi'),
deb: () => this._getType('deb'),
debsrc: () => this._getType('debsrc'),
rpm: () => this._getType('rpm'),
}
}

Expand Down
4 changes: 4 additions & 0 deletions docs/determining-declared-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@
* source: https://cocoapods.org/
* The service then sets the declared license based on the registry information
* The ClearlyDefined summarizer pulls registry information from 'https://raw.githubusercontent.com/CocoaPods/Specs/master

### rpm
* source: packages.microsoft.com
* TODO
4 changes: 3 additions & 1 deletion lib/licenseMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ class HarvestLicenseMatchPolicy {
return new BaseHarvestLicenseMatchStrategy('deb', ['declaredLicenses'])
case 'debsrc':
return new BaseHarvestLicenseMatchStrategy('debsrc', ['declaredLicenses'])
case 'rpm':
return new BaseHarvestLicenseMatchStrategy('rpm', ['declaredLicense'])
default:
return new BaseHarvestLicenseMatchStrategy('default')
}
Expand Down Expand Up @@ -212,4 +214,4 @@ module.exports = {
LicenseMatcher,
DefinitionLicenseMatchPolicy,
HarvestLicenseMatchPolicy
}
}
17 changes: 17 additions & 0 deletions providers/summary/clearlydefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class ClearlyDescribedSummarizer {
case 'debsrc':
this.addDebSrcData(result, data, coordinates)
break
case 'rpm':
this.addRpmData(result, data, coordinates)
break
default:
}
return result
Expand All @@ -89,6 +92,9 @@ class ClearlyDescribedSummarizer {
}

addSourceLocation(result, data) {
// It's not deducible where the source of RPMs are - in this case
// we rely on the crawler to tell us.
setIfValue(result, 'described.sourceLocation', get(data, 'registryData.srcRpmUrl'))
if (!data.sourceInfo) return
const spec = data.sourceInfo
updateSourceLocation(spec)
Expand Down Expand Up @@ -470,6 +476,17 @@ class ClearlyDescribedSummarizer {
return null
}

addRpmData(result, data, coordinates) {
setIfValue(result, 'described.releaseDate', extractDate(data.releaseDate))
if (!data.registryData) return
if (result.described.sourceLocation) {
result.described.sourceLocation.url = data.registryData.srcRpmUrl
}
setIfValue(result, 'licensed.declared', SPDX.normalize(data.declaredLicense))
setIfValue(result, 'described.urls.registry', data.registryData.rpmUrl)
setIfValue(result, 'described.urls.download', data.registryData.rpmUrl)
}

addGoData(result, data, coordinates) {
var urls = { download: '', registry: '', version: '' }

Expand Down
8 changes: 5 additions & 3 deletions schemas/coordinates-1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"pypi",
"sourcearchive",
"deb",
"debsrc"
"debsrc",
"rpm"
],
"errorMessage": {
"type": "coordinates.type must be a string"
Expand All @@ -44,7 +45,8 @@
"nuget",
"rubygems",
"pypi",
"debian"
"debian",
"mariner"
],
"errorMessage": {
"type": "coordinates.provider must be a string"
Expand All @@ -69,4 +71,4 @@
}
}
}
}
}
8 changes: 5 additions & 3 deletions schemas/curation-1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"pypi",
"sourcearchive",
"deb",
"debsrc"
"debsrc",
"rpm"
],
"errorMessage": {
"enum": "Package type must be supported by ClearlyDefined",
Expand All @@ -58,7 +59,8 @@
"nuget",
"rubygems",
"pypi",
"debian"
"debian",
"mariner"
],
"errorMessage": {
"enum": "Provider type must be supported by ClearlyDefined",
Expand Down Expand Up @@ -258,4 +260,4 @@
}
}
}
}
}
8 changes: 5 additions & 3 deletions schemas/curations-1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"pypi",
"sourcearchive",
"deb",
"debsrc"
"debsrc",
"rpm"
],
"errorMessage": {
"enum": "Package type must be supported by ClearlyDefined",
Expand All @@ -60,7 +61,8 @@
"nuget",
"rubygems",
"pypi",
"debian"
"debian",
"mariner"
],
"errorMessage": {
"enum": "Provider type must be supported by ClearlyDefined",
Expand Down Expand Up @@ -115,4 +117,4 @@
}
}
}
}
}
8 changes: 5 additions & 3 deletions schemas/definition-1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"pypi",
"sourcearchive",
"deb",
"debsrc"
"debsrc",
"rpm"
]
},
"provider": {
Expand All @@ -61,7 +62,8 @@
"nuget",
"rubygems",
"pypi",
"debian"
"debian",
"mariner"
]
},
"_meta": {
Expand Down Expand Up @@ -471,4 +473,4 @@
}
}
}
}
}
2 changes: 2 additions & 0 deletions schemas/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ components:
- pod
- pypi
- sourcearchive
- rpm
provider:
name: provider
in: path
Expand All @@ -564,6 +565,7 @@ components:
- packagist
- pypi
- rubygems
- mariner
namespace:
name: namespace
in: path
Expand Down
13 changes: 13 additions & 0 deletions test/summary/clearlydefinedTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,19 @@ describe('ClearlyDescribedSummarizer addDebSrcData', () => {
})
})

describe('ClearlyDescribedSummarizer addRpmData', () => {
const coordinates = EntityCoordinates.fromString('rpm/mariner/-/test/1.0-1.cm2.x86_64')
it('describes releaseDate from data', () => {
let result = { described: { sourceLocation: {} } }
summarizer.addRpmData(result, {
releaseDate: '2018-06-01T21:41:57.990052+00:00',
registryData: { srcRpmUrl: "https://packages.microsoft.com/src.rpm" }
}, coordinates)
assert.strictEqual(result.described.releaseDate, '2018-06-01')
assert.strictEqual(result.described.sourceLocation.url, 'https://packages.microsoft.com/src.rpm')
})
})

describe('ClearlyDescribedSummarizer addGitData', () => {
const testCoordinatesGit = EntityCoordinates.fromString('git/github/test_namespace/test/71eee1980b')

Expand Down