jfrog-client-js
Advanced tools
Comparing version 2.7.1 to 2.8.0
@@ -19,1 +19,3 @@ export { IAqlSearchResult } from './Artifactory/Search/AqlSearchResult'; | ||
export { RetryOnStatusCode } from './ClientConfig'; | ||
export * from './Xsc/Event'; | ||
export { IXscVersion } from './Xsc/System/Version'; |
@@ -19,2 +19,3 @@ "use strict"; | ||
__exportStar(require("./Xray/Summary"), exports); | ||
__exportStar(require("./Xsc/Event"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -69,3 +69,3 @@ import { IClientResponse, ILogger, IProxyConfig, RetryOnStatusCode } from '../model'; | ||
} | ||
export declare type method = 'GET' | 'POST' | 'HEAD'; | ||
export declare type method = 'GET' | 'POST' | 'HEAD' | 'PUT'; | ||
export declare type responseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'; | ||
@@ -72,0 +72,0 @@ export interface IRequestParams { |
@@ -11,2 +11,4 @@ export { ArtifactoryDownloadClient } from './Artifactory/ArtifactoryDownloadClient'; | ||
export { XrayScanProgress } from './Xray/XrayScanProgress'; | ||
export { XscEventClient } from './Xsc/XscEventClient'; | ||
export { XscSystemClient } from './Xsc/XscSystemClient'; | ||
export { ClientUtils } from './ClientUtils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClientUtils = exports.XraySystemClient = exports.XraySummaryClient = exports.XrayGraphClient = exports.XrayDetailsClient = exports.JfrogClient = exports.HttpClient = exports.ArtifactorySystemClient = exports.ArtifactorySearchClient = exports.ArtifactoryDownloadClient = void 0; | ||
exports.ClientUtils = exports.XscSystemClient = exports.XscEventClient = exports.XraySystemClient = exports.XraySummaryClient = exports.XrayGraphClient = exports.XrayDetailsClient = exports.JfrogClient = exports.HttpClient = exports.ArtifactorySystemClient = exports.ArtifactorySearchClient = exports.ArtifactoryDownloadClient = void 0; | ||
var ArtifactoryDownloadClient_1 = require("./Artifactory/ArtifactoryDownloadClient"); | ||
@@ -22,4 +22,8 @@ Object.defineProperty(exports, "ArtifactoryDownloadClient", { enumerable: true, get: function () { return ArtifactoryDownloadClient_1.ArtifactoryDownloadClient; } }); | ||
Object.defineProperty(exports, "XraySystemClient", { enumerable: true, get: function () { return XraySystemClient_1.XraySystemClient; } }); | ||
var XscEventClient_1 = require("./Xsc/XscEventClient"); | ||
Object.defineProperty(exports, "XscEventClient", { enumerable: true, get: function () { return XscEventClient_1.XscEventClient; } }); | ||
var XscSystemClient_1 = require("./Xsc/XscSystemClient"); | ||
Object.defineProperty(exports, "XscSystemClient", { enumerable: true, get: function () { return XscSystemClient_1.XscSystemClient; } }); | ||
var ClientUtils_1 = require("./ClientUtils"); | ||
Object.defineProperty(exports, "ClientUtils", { enumerable: true, get: function () { return ClientUtils_1.ClientUtils; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
import { ArtifactoryClient } from './Artifactory/ArtifactoryClient'; | ||
import { XscClient } from './Xsc/XscClient'; | ||
import * as os from 'os'; | ||
@@ -12,2 +13,3 @@ import { PlatformClient } from './Platform/PlatformClient'; | ||
private static readonly XRAY_SUFFIX; | ||
private static readonly XSC_SUFFIX; | ||
readonly clientId?: string; | ||
@@ -18,2 +20,3 @@ constructor(_jfrogConfig: IJfrogClientConfig); | ||
platform(): PlatformClient; | ||
xsc(): XscClient; | ||
/** | ||
@@ -20,0 +23,0 @@ * Creates a server specific config from the provided JFrog config. |
@@ -32,2 +32,3 @@ "use strict"; | ||
const ArtifactoryClient_1 = require("./Artifactory/ArtifactoryClient"); | ||
const XscClient_1 = require("./Xsc/XscClient"); | ||
const os = __importStar(require("os")); | ||
@@ -57,2 +58,5 @@ const crypto_1 = __importDefault(require("crypto")); // Important - Don't import '*'. It'll import deprecated encryption methods | ||
} | ||
xsc() { | ||
return new XscClient_1.XscClient(this.getSpecificClientConfig(JfrogClient.XSC_SUFFIX)); | ||
} | ||
/** | ||
@@ -94,2 +98,3 @@ * Creates a server specific config from the provided JFrog config. | ||
JfrogClient.XRAY_SUFFIX = 'xray'; | ||
JfrogClient.XSC_SUFFIX = 'xsc'; | ||
//# sourceMappingURL=JfrogClient.js.map |
@@ -8,2 +8,3 @@ import { XraySystemClient } from './XraySystemClient'; | ||
export declare class XrayClient { | ||
static readonly scanGraphEndpoint: string; | ||
private readonly httpClient; | ||
@@ -10,0 +11,0 @@ private logger; |
@@ -41,3 +41,3 @@ "use strict"; | ||
scan() { | ||
return new __1.XrayGraphClient(this.httpClient, this.logger); | ||
return new __1.XrayGraphClient(this.httpClient, XrayClient.scanGraphEndpoint, this.logger); | ||
} | ||
@@ -49,2 +49,3 @@ entitlements() { | ||
exports.XrayClient = XrayClient; | ||
XrayClient.scanGraphEndpoint = 'api/v1/scan/graph'; | ||
//# sourceMappingURL=XrayClient.js.map |
@@ -6,8 +6,8 @@ import { HttpClient } from '..'; | ||
private readonly httpClient; | ||
private readonly endPoint; | ||
private readonly logger; | ||
static readonly scanGraphEndpoint: string; | ||
private static readonly SLEEP_INTERVAL_MILLISECONDS; | ||
private static readonly MAX_ATTEMPTS; | ||
constructor(httpClient: HttpClient, logger: ILogger); | ||
graph(request: IGraphRequestModel, progress: XrayScanProgress, checkCanceled: () => void, projectKey: string | undefined, watches: string[] | undefined, sleepIntervalMilliseconds?: number): Promise<IGraphResponse>; | ||
constructor(httpClient: HttpClient, endPoint: string, logger: ILogger); | ||
graph(request: IGraphRequestModel, progress: XrayScanProgress, checkCanceled: () => void, projectKey: string | undefined, watches: string[] | undefined, multiScanId?: string, technologies?: string[], sleepIntervalMilliseconds?: number): Promise<IGraphResponse>; | ||
/** | ||
@@ -25,9 +25,13 @@ * | ||
/** | ||
* Get URL for "POST api/v1/scan/graph". | ||
* If no project key provided - api/v1/scan/graph | ||
* If project key was provided - api/v1/scan/graph?project=<projectKey> | ||
* If watches provided - api/v1/scan/graph?watch=<watch-1>&watch=<watch-2> | ||
* Get URL for "POST scan/graph" (Xray: api/v1/scan/graph, XSC: api/v1/sca/scan/graph). | ||
* If no project key provided - /scan/graph | ||
* If project key was provided - /scan/graph?project=<projectKey> | ||
* If watches provided - /scan/graph?watch=<watch-1>&watch=<watch-2> | ||
* If multiScanId provided - /scan/graph?multi_scan_id=<multiScanId> | ||
* If technologies provided - /scan/graph?tech=<tech-1>&tech=<tech-2> | ||
* @param projectKey - Project key or undefined | ||
* @param watches - List of Watches or undefined | ||
* @returns URL for "POST api/v1/scan/graph" | ||
* @param multiScanId - Multi scan ID or undefined | ||
* @param technologies - List of technologies or undefined | ||
* @returns URL for "POST /scan/graph" | ||
*/ | ||
@@ -34,0 +38,0 @@ private getUrl; |
@@ -5,7 +5,8 @@ "use strict"; | ||
class XrayScanClient { | ||
constructor(httpClient, logger) { | ||
constructor(httpClient, endPoint, logger) { | ||
this.httpClient = httpClient; | ||
this.endPoint = endPoint; | ||
this.logger = logger; | ||
} | ||
async graph(request, progress, checkCanceled, projectKey, watches, sleepIntervalMilliseconds = XrayScanClient.SLEEP_INTERVAL_MILLISECONDS) { | ||
async graph(request, progress, checkCanceled, projectKey, watches, multiScanId, technologies, sleepIntervalMilliseconds = XrayScanClient.SLEEP_INTERVAL_MILLISECONDS) { | ||
try { | ||
@@ -16,3 +17,3 @@ if (!request) { | ||
checkCanceled(); | ||
const response = await this.postScanGraph(request, projectKey, watches); | ||
const response = await this.postScanGraph(request, projectKey, watches, multiScanId, technologies); | ||
return await this.getScanGraphResults(response.data.scan_id, progress, checkCanceled, (!projectKey || projectKey.length === 0) && (!watches || watches.length === 0), sleepIntervalMilliseconds); | ||
@@ -34,7 +35,7 @@ } | ||
*/ | ||
async postScanGraph(request, projectKey, watches) { | ||
async postScanGraph(request, projectKey, watches, multiScanId, technologies) { | ||
var _a, _b, _c, _d; | ||
this.logger.debug('Sending POST scan/graph request...'); | ||
const requestParams = { | ||
url: this.getUrl(projectKey, watches), | ||
url: this.getUrl(projectKey, watches, multiScanId, technologies), | ||
method: 'POST', | ||
@@ -61,19 +62,30 @@ data: request, | ||
/** | ||
* Get URL for "POST api/v1/scan/graph". | ||
* If no project key provided - api/v1/scan/graph | ||
* If project key was provided - api/v1/scan/graph?project=<projectKey> | ||
* If watches provided - api/v1/scan/graph?watch=<watch-1>&watch=<watch-2> | ||
* Get URL for "POST scan/graph" (Xray: api/v1/scan/graph, XSC: api/v1/sca/scan/graph). | ||
* If no project key provided - /scan/graph | ||
* If project key was provided - /scan/graph?project=<projectKey> | ||
* If watches provided - /scan/graph?watch=<watch-1>&watch=<watch-2> | ||
* If multiScanId provided - /scan/graph?multi_scan_id=<multiScanId> | ||
* If technologies provided - /scan/graph?tech=<tech-1>&tech=<tech-2> | ||
* @param projectKey - Project key or undefined | ||
* @param watches - List of Watches or undefined | ||
* @returns URL for "POST api/v1/scan/graph" | ||
* @param multiScanId - Multi scan ID or undefined | ||
* @param technologies - List of technologies or undefined | ||
* @returns URL for "POST /scan/graph" | ||
*/ | ||
getUrl(projectKey, watches) { | ||
let url = XrayScanClient.scanGraphEndpoint; | ||
getUrl(projectKey, watches, multiScanId, technologies) { | ||
let url = this.endPoint; | ||
let params = []; | ||
if (projectKey && projectKey.length > 0) { | ||
url += `?project=${projectKey}`; | ||
params.push(`project=${projectKey}`); | ||
} | ||
else if (watches && watches.length > 0) { | ||
url += '?watch=' + watches.join('&watch='); | ||
params.push(`watch=${watches.join('&watch=')}`); | ||
} | ||
return url; | ||
if (multiScanId) { | ||
params.push(`multi_scan_id=${multiScanId}`); | ||
} | ||
if (technologies && technologies.length > 0) { | ||
params.push(`tech=${technologies.join('&tech=')}`); | ||
} | ||
return params.length > 0 ? url + '?' + params.join('&') : url; | ||
} | ||
@@ -95,3 +107,3 @@ /** | ||
async getScanGraphResults(scanId, progress, checkCanceled, includeVulnerabilities, sleepIntervalMilliseconds) { | ||
const scanGraphUrl = XrayScanClient.scanGraphEndpoint + | ||
const scanGraphUrl = this.endPoint + | ||
'/' + | ||
@@ -145,5 +157,4 @@ scanId + | ||
exports.XrayScanClient = XrayScanClient; | ||
XrayScanClient.scanGraphEndpoint = 'api/v1/scan/graph'; | ||
XrayScanClient.SLEEP_INTERVAL_MILLISECONDS = 5000; | ||
XrayScanClient.MAX_ATTEMPTS = 60; | ||
//# sourceMappingURL=XrayScanClient.js.map |
{ | ||
"name": "jfrog-client-js", | ||
"version": "2.7.1", | ||
"version": "2.8.0", | ||
"description": "JFrog Javascript Client is a javascript library, which wraps some of the REST APIs exposed by JFrog Services's different services.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -45,2 +45,8 @@ # JFrog Javascript Client | ||
- [Get Access Token From Web Login](#get-access-token-from-web-login) | ||
- [Xray Source Control](#xray-source-control) | ||
- [Getting Xsc Version](#getting-xsc-version) | ||
- [Sending Log Message Event](#sending-log-mesage-event) | ||
- [Sending Start Scan Event](#sending-start-scan-event) | ||
- [Sending End Scan Event](#sending-end-scan-event) | ||
- [Getting Scan Event Details](#getting-scan-event-details) | ||
@@ -347,1 +353,83 @@ ### Setting up JFrog client | ||
Please note that you need to replace 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' with the actual session ID that you've generated for `registerSessionId`. | ||
### Xray Source Control | ||
#### System | ||
##### Getting Xsc Version | ||
```javascript | ||
jfrogClient | ||
.xsc() | ||
.system() | ||
.version() | ||
.then((result) => { | ||
console.log(result); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
``` | ||
#### Event | ||
##### Sending Log Message Event | ||
```javascript | ||
jfrogClient | ||
.xsc() | ||
.event() | ||
.log({log_level: 'error', source: 'js-client', message: 'error message to report as an event'}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
``` | ||
##### Sending Start Scan Event | ||
```javascript | ||
jfrogClient | ||
.xsc() | ||
.event() | ||
.startScan({product: 'product', os_platform: 'windows', jfrog_user: 'user-name'}) | ||
.then((result) => { | ||
console.log(result); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
``` | ||
##### Sending End Scan Event | ||
```javascript | ||
const scanEvent = {multi_scan_id: 'some-scan-id', event_status: 'completed'} | ||
jfrogClient | ||
.xsc() | ||
.event() | ||
.endScan({product: 'product', os_platform: 'windows', jfrog_user: 'user-name'}) | ||
.then((result) => { | ||
console.log(result); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
``` | ||
##### Getting Scan Event Details | ||
```javascript | ||
const multiScanId = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX // UUID | ||
jfrogClient | ||
.xsc() | ||
.event() | ||
.getScanEvent(multiScanId) | ||
.then((result) => { | ||
... | ||
}) | ||
.catch((error) => { | ||
... | ||
}); | ||
``` | ||
Please note that you need to replace 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' with the actual multi scan ID that you've generated with `startScan`. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139936
234
2006
434