mobbdev 0.0.68 → 0.0.69
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/dist/index.mjs +97 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -274,6 +274,7 @@ var SUBMIT_VULNERABILITY_REPORT = gql`
|
|
|
274
274
|
$reference: String!
|
|
275
275
|
$projectId: String!
|
|
276
276
|
$sha: String
|
|
277
|
+
$experimentalEnabled: Boolean
|
|
277
278
|
$vulnerabilityReportFileName: String
|
|
278
279
|
$pullRequest: Int
|
|
279
280
|
) {
|
|
@@ -282,6 +283,7 @@ var SUBMIT_VULNERABILITY_REPORT = gql`
|
|
|
282
283
|
repoUrl: $repoUrl
|
|
283
284
|
reference: $reference
|
|
284
285
|
sha: $sha
|
|
286
|
+
experimentalEnabled: $experimentalEnabled
|
|
285
287
|
pullRequest: $pullRequest
|
|
286
288
|
projectId: $projectId
|
|
287
289
|
vulnerabilityReportFileName: $vulnerabilityReportFileName
|
|
@@ -813,6 +815,7 @@ var GQLClient = class {
|
|
|
813
815
|
reference,
|
|
814
816
|
projectId,
|
|
815
817
|
sha,
|
|
818
|
+
experimentalEnabled,
|
|
816
819
|
vulnerabilityReportFileName,
|
|
817
820
|
pullRequest
|
|
818
821
|
} = params;
|
|
@@ -823,7 +826,8 @@ var GQLClient = class {
|
|
|
823
826
|
vulnerabilityReportFileName,
|
|
824
827
|
projectId,
|
|
825
828
|
pullRequest,
|
|
826
|
-
sha: sha || ""
|
|
829
|
+
sha: sha || "",
|
|
830
|
+
experimentalEnabled
|
|
827
831
|
});
|
|
828
832
|
return CreateUpdateFixReportMutationZ.parse(res);
|
|
829
833
|
}
|
|
@@ -1311,6 +1315,73 @@ async function getGithubBlameRanges({ ref, gitHubUrl, path: path8 }, options) {
|
|
|
1311
1315
|
login: range.commit.author.user.login
|
|
1312
1316
|
}));
|
|
1313
1317
|
}
|
|
1318
|
+
async function createPr({
|
|
1319
|
+
sourceRepoUrl,
|
|
1320
|
+
sourceFilePath,
|
|
1321
|
+
targetFilePath,
|
|
1322
|
+
userRepoUrl,
|
|
1323
|
+
title
|
|
1324
|
+
}, options) {
|
|
1325
|
+
const oktoKit = getOktoKit(options);
|
|
1326
|
+
const { owner: sourceOwner, repo: sourceRepo } = parseOwnerAndRepo(sourceRepoUrl);
|
|
1327
|
+
const { owner, repo } = parseOwnerAndRepo(userRepoUrl);
|
|
1328
|
+
const sourceFileContentResponse = await oktoKit.rest.repos.getContent({
|
|
1329
|
+
owner: sourceOwner,
|
|
1330
|
+
repo: sourceRepo,
|
|
1331
|
+
path: "/" + sourceFilePath
|
|
1332
|
+
});
|
|
1333
|
+
const newBranchName = `mobb/workflow-${Date.now()}`;
|
|
1334
|
+
oktoKit.rest.git.createRef({
|
|
1335
|
+
owner,
|
|
1336
|
+
repo,
|
|
1337
|
+
ref: `refs/heads/${newBranchName}`,
|
|
1338
|
+
sha: await oktoKit.rest.git.getRef({ owner, repo, ref: "heads/main" }).then((response) => response.data.object.sha)
|
|
1339
|
+
});
|
|
1340
|
+
const decodedContent = Buffer.from(
|
|
1341
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1342
|
+
// @ts-ignore
|
|
1343
|
+
sourceFileContentResponse.data.content,
|
|
1344
|
+
"base64"
|
|
1345
|
+
).toString("utf-8");
|
|
1346
|
+
const createTreeResponse = await oktoKit.rest.git.createTree({
|
|
1347
|
+
owner,
|
|
1348
|
+
repo,
|
|
1349
|
+
base_tree: await oktoKit.rest.git.getRef({ owner, repo, ref: `heads/main` }).then((response) => response.data.object.sha),
|
|
1350
|
+
tree: [
|
|
1351
|
+
{
|
|
1352
|
+
path: targetFilePath,
|
|
1353
|
+
mode: "100644",
|
|
1354
|
+
type: "blob",
|
|
1355
|
+
content: decodedContent
|
|
1356
|
+
}
|
|
1357
|
+
]
|
|
1358
|
+
});
|
|
1359
|
+
const createCommitResponse = await oktoKit.rest.git.createCommit({
|
|
1360
|
+
owner,
|
|
1361
|
+
repo,
|
|
1362
|
+
message: "Add new yaml file",
|
|
1363
|
+
tree: createTreeResponse.data.sha,
|
|
1364
|
+
parents: [
|
|
1365
|
+
await oktoKit.rest.git.getRef({ owner, repo, ref: `heads/main` }).then((response) => response.data.object.sha)
|
|
1366
|
+
]
|
|
1367
|
+
});
|
|
1368
|
+
await oktoKit.rest.git.updateRef({
|
|
1369
|
+
owner,
|
|
1370
|
+
repo,
|
|
1371
|
+
ref: `heads/${newBranchName}`,
|
|
1372
|
+
sha: createCommitResponse.data.sha
|
|
1373
|
+
});
|
|
1374
|
+
const createPRResponse = await oktoKit.rest.pulls.create({
|
|
1375
|
+
owner,
|
|
1376
|
+
repo,
|
|
1377
|
+
title,
|
|
1378
|
+
head: newBranchName,
|
|
1379
|
+
base: "main"
|
|
1380
|
+
});
|
|
1381
|
+
return {
|
|
1382
|
+
pull_request_url: createPRResponse.data.html_url
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1314
1385
|
|
|
1315
1386
|
// src/features/analysis/scm/github/consts.ts
|
|
1316
1387
|
var POST_COMMENT_PATH = "POST /repos/{owner}/{repo}/pulls/{pull_number}/comments";
|
|
@@ -1607,6 +1678,9 @@ var GitlabSCMLib = class extends SCMLib {
|
|
|
1607
1678
|
}
|
|
1608
1679
|
throw new Error("not supported yet");
|
|
1609
1680
|
}
|
|
1681
|
+
async createPullRequestWithNewFile(_sourceRepoUrl, _sourceFilePath, _targetFilePath, _userRepoUrl, _title) {
|
|
1682
|
+
throw new Error("not implemented");
|
|
1683
|
+
}
|
|
1610
1684
|
async getRepoList() {
|
|
1611
1685
|
if (!this.accessToken) {
|
|
1612
1686
|
console.error("no access token");
|
|
@@ -1791,6 +1865,21 @@ var GithubSCMLib = class extends SCMLib {
|
|
|
1791
1865
|
repo
|
|
1792
1866
|
});
|
|
1793
1867
|
}
|
|
1868
|
+
async createPullRequestWithNewFile(sourceRepoUrl, sourceFilePath, targetFilePath, userRepoUrl, title) {
|
|
1869
|
+
const { pull_request_url } = await createPr(
|
|
1870
|
+
{
|
|
1871
|
+
sourceRepoUrl,
|
|
1872
|
+
sourceFilePath,
|
|
1873
|
+
targetFilePath,
|
|
1874
|
+
userRepoUrl,
|
|
1875
|
+
title
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
githubAuthToken: this.accessToken
|
|
1879
|
+
}
|
|
1880
|
+
);
|
|
1881
|
+
return { pull_request_url };
|
|
1882
|
+
}
|
|
1794
1883
|
async validateParams() {
|
|
1795
1884
|
return githubValidateParams(this.url, this.accessToken);
|
|
1796
1885
|
}
|
|
@@ -2006,6 +2095,10 @@ var StubSCMLib = class extends SCMLib {
|
|
|
2006
2095
|
console.error("forkRepo() not implemented");
|
|
2007
2096
|
throw new Error("forkRepo() not implemented");
|
|
2008
2097
|
}
|
|
2098
|
+
async createPullRequestWithNewFile(_sourceRepoUrl, _sourceFilePath, _targetFilePath, _userRepoUrl, _title) {
|
|
2099
|
+
console.error("createPullRequestWithNewFile() not implemented");
|
|
2100
|
+
throw new Error("createPullRequestWithNewFile() not implemented");
|
|
2101
|
+
}
|
|
2009
2102
|
async getRepoList() {
|
|
2010
2103
|
console.error("getBranchList() not implemented");
|
|
2011
2104
|
throw new Error("getBranchList() not implemented");
|
|
@@ -3049,6 +3142,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
3049
3142
|
srcPath,
|
|
3050
3143
|
commitHash,
|
|
3051
3144
|
ref,
|
|
3145
|
+
experimentalEnabled,
|
|
3052
3146
|
scanner,
|
|
3053
3147
|
cxProjectName,
|
|
3054
3148
|
mobbProjectName,
|
|
@@ -3167,6 +3261,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
3167
3261
|
projectId,
|
|
3168
3262
|
vulnerabilityReportFileName: "report.json",
|
|
3169
3263
|
sha,
|
|
3264
|
+
experimentalEnabled,
|
|
3170
3265
|
pullRequest: params.pullRequest
|
|
3171
3266
|
});
|
|
3172
3267
|
if (sumbitRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
|
|
@@ -3412,6 +3507,7 @@ async function review(params, { skipPrompts = true } = {}) {
|
|
|
3412
3507
|
apiKey,
|
|
3413
3508
|
ci: true,
|
|
3414
3509
|
commitHash,
|
|
3510
|
+
experimentalEnabled: false,
|
|
3415
3511
|
mobbProjectName,
|
|
3416
3512
|
pullRequest,
|
|
3417
3513
|
githubToken,
|