@renovatebot/osv-offline-db 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +31 -0
- package/dist/lib/db.d.ts +10 -0
- package/dist/lib/db.js +44 -0
- package/dist/lib/ecosystem.d.ts +5 -0
- package/dist/lib/ecosystem.js +15 -0
- package/dist/lib/osv.d.ts +62 -0
- package/dist/lib/osv.js +2 -0
- package/package.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Jamie Magee <jamie.magee@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# osv-offline-db
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@renovatebot/osv-offline-db)
|
|
4
|
+
[](https://github.com/jamiemagee/osv-offline/actions/workflows/build.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## License
|
|
9
|
+
|
|
10
|
+
This package is licensed under [the MIT license](https://opensource.org/licenses/MIT).
|
|
11
|
+
|
|
12
|
+
Vulnerabilities are provided from the following upstream data sources and licenses:
|
|
13
|
+
|
|
14
|
+
- [GitHub Advisory Database](https://github.com/github/advisory-database) ([CC-BY 4.0](https://github.com/github/advisory-database/blob/main/LICENSE.md))
|
|
15
|
+
- [PyPI Advisory Database](https://github.com/pypa/advisory-database) ([CC-BY 4.0](https://github.com/pypa/advisory-database/blob/main/LICENSE))
|
|
16
|
+
- [Go Vulnerability Database](https://github.com/golang/vulndb) ([CC-BY 4.0](https://github.com/golang/vulndb#license))
|
|
17
|
+
- [Rust Advisory Database](https://github.com/RustSec/advisory-db) ([CC0 1.0](https://github.com/rustsec/advisory-db/blob/main/LICENSE.txt))
|
|
18
|
+
- [Global Security Database](https://github.com/cloudsecurityalliance/gsd-database) ([CC0 1.0](https://github.com/cloudsecurityalliance/gsd-database/blob/main/LICENSE))
|
|
19
|
+
- [OSS-Fuzz](https://github.com/google/oss-fuzz-vulns) ([CC-BY 4.0](https://github.com/google/oss-fuzz-vulns/blob/main/LICENSE))
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Osv = exports.ecosystems = exports.OsvOfflineDb = void 0;
|
|
27
|
+
var db_1 = require("./lib/db");
|
|
28
|
+
Object.defineProperty(exports, "OsvOfflineDb", { enumerable: true, get: function () { return db_1.OsvOfflineDb; } });
|
|
29
|
+
var ecosystem_1 = require("./lib/ecosystem");
|
|
30
|
+
Object.defineProperty(exports, "ecosystems", { enumerable: true, get: function () { return ecosystem_1.ecosystems; } });
|
|
31
|
+
exports.Osv = __importStar(require("./lib/osv"));
|
package/dist/lib/db.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Ecosystem } from './ecosystem';
|
|
2
|
+
import { Osv } from '..';
|
|
3
|
+
export declare class OsvOfflineDb {
|
|
4
|
+
static readonly rootDirectory: string;
|
|
5
|
+
private db;
|
|
6
|
+
private constructor();
|
|
7
|
+
private initialize;
|
|
8
|
+
static create(): Promise<OsvOfflineDb>;
|
|
9
|
+
query(ecosystem: Ecosystem, packageName: string): Promise<Osv.Vulnerability[]>;
|
|
10
|
+
}
|
package/dist/lib/db.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OsvOfflineDb = void 0;
|
|
7
|
+
const os_1 = require("os");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const nedb_1 = __importDefault(require("@seald-io/nedb"));
|
|
10
|
+
const ecosystem_1 = require("./ecosystem");
|
|
11
|
+
class OsvOfflineDb {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
13
|
+
constructor() {
|
|
14
|
+
this.db = {};
|
|
15
|
+
}
|
|
16
|
+
async initialize() {
|
|
17
|
+
for (const ecosystem of ecosystem_1.ecosystems) {
|
|
18
|
+
this.db[ecosystem] = new nedb_1.default({
|
|
19
|
+
filename: path_1.default.join(OsvOfflineDb.rootDirectory, `${ecosystem.toLowerCase()}.nedb`),
|
|
20
|
+
});
|
|
21
|
+
await this.db[ecosystem].loadDatabaseAsync();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static async create() {
|
|
25
|
+
const osvOfflineDb = new OsvOfflineDb();
|
|
26
|
+
await osvOfflineDb.initialize();
|
|
27
|
+
return osvOfflineDb;
|
|
28
|
+
}
|
|
29
|
+
async query(ecosystem, packageName) {
|
|
30
|
+
return await this.db[ecosystem].findAsync({
|
|
31
|
+
affected: {
|
|
32
|
+
$elemMatch: {
|
|
33
|
+
package: {
|
|
34
|
+
name: packageName,
|
|
35
|
+
ecosystem,
|
|
36
|
+
purl: `pkg:${ecosystem.toLowerCase()}/${packageName}`,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.OsvOfflineDb = OsvOfflineDb;
|
|
44
|
+
OsvOfflineDb.rootDirectory = path_1.default.join((0, os_1.tmpdir)(), 'osv-offline');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://github.com/google/osv/blob/b9f0d1c1b377b0ab5804808f24032be965a571b8/lib/osv/ecosystems.py#L313-L321
|
|
3
|
+
*/
|
|
4
|
+
export declare const ecosystems: readonly ["crates.io", "Go", "Maven", "npm", "NuGet", "PyPI", "RubyGems"];
|
|
5
|
+
export declare type Ecosystem = typeof ecosystems[number];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ecosystems = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* https://github.com/google/osv/blob/b9f0d1c1b377b0ab5804808f24032be965a571b8/lib/osv/ecosystems.py#L313-L321
|
|
6
|
+
*/
|
|
7
|
+
exports.ecosystems = [
|
|
8
|
+
'crates.io',
|
|
9
|
+
'Go',
|
|
10
|
+
'Maven',
|
|
11
|
+
'npm',
|
|
12
|
+
'NuGet',
|
|
13
|
+
'PyPI',
|
|
14
|
+
'RubyGems',
|
|
15
|
+
];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A schema for describing a vulnerability in an open source package.
|
|
3
|
+
*/
|
|
4
|
+
export interface Vulnerability {
|
|
5
|
+
affected?: Affected[];
|
|
6
|
+
aliases?: string[];
|
|
7
|
+
credits?: Credit[];
|
|
8
|
+
databaseSpecific?: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
details?: string;
|
|
12
|
+
id: string;
|
|
13
|
+
modified: Date;
|
|
14
|
+
published?: Date;
|
|
15
|
+
references?: Reference[];
|
|
16
|
+
related?: string[];
|
|
17
|
+
schemaVersion?: string;
|
|
18
|
+
severity?: Severity[];
|
|
19
|
+
summary?: string;
|
|
20
|
+
withdrawn?: Date;
|
|
21
|
+
}
|
|
22
|
+
export interface Affected {
|
|
23
|
+
databaseSpecific?: {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
ecosystemSpecific?: {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
package?: Package;
|
|
30
|
+
ranges?: Range[];
|
|
31
|
+
versions?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface Package {
|
|
34
|
+
ecosystem: string;
|
|
35
|
+
name: string;
|
|
36
|
+
purl?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface Range {
|
|
39
|
+
events: Event[];
|
|
40
|
+
repo?: string;
|
|
41
|
+
type: RangeType;
|
|
42
|
+
}
|
|
43
|
+
export interface Event {
|
|
44
|
+
introduced?: string;
|
|
45
|
+
fixed?: string;
|
|
46
|
+
limit?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare type RangeType = 'ECOSYSTEM' | 'GIT' | 'SEMVER';
|
|
49
|
+
export interface Credit {
|
|
50
|
+
contact?: string[];
|
|
51
|
+
name: string;
|
|
52
|
+
}
|
|
53
|
+
export interface Reference {
|
|
54
|
+
type: ReferenceType;
|
|
55
|
+
url: string;
|
|
56
|
+
}
|
|
57
|
+
export declare type ReferenceType = 'ADVISORY' | 'ARTICLE' | 'FIX' | 'GIT' | 'PACKAGE' | 'REPORT' | 'WEB';
|
|
58
|
+
export interface Severity {
|
|
59
|
+
score: string;
|
|
60
|
+
type: SeverityType;
|
|
61
|
+
}
|
|
62
|
+
export declare type SeverityType = 'CVSS_V3';
|
package/dist/lib/osv.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@renovatebot/osv-offline-db",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@seald-io/nedb": "3.0.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@tsconfig/node14": "1.0.3",
|
|
15
|
+
"@types/node": "16.11.52",
|
|
16
|
+
"prettier": "2.7.1",
|
|
17
|
+
"ts-node": "10.9.1",
|
|
18
|
+
"typescript": "4.7.4"
|
|
19
|
+
}
|
|
20
|
+
}
|