mobbdev 0.0.68 → 0.0.70
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 +99 -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,75 @@ 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 { data: repository } = await oktoKit.rest.repos.get({ owner, repo });
|
|
1334
|
+
const defaultBranch = repository.default_branch;
|
|
1335
|
+
const newBranchName = `mobb/workflow-${Date.now()}`;
|
|
1336
|
+
oktoKit.rest.git.createRef({
|
|
1337
|
+
owner,
|
|
1338
|
+
repo,
|
|
1339
|
+
ref: `refs/heads/${newBranchName}`,
|
|
1340
|
+
sha: await oktoKit.rest.git.getRef({ owner, repo, ref: `heads/${defaultBranch}` }).then((response) => response.data.object.sha)
|
|
1341
|
+
});
|
|
1342
|
+
const decodedContent = Buffer.from(
|
|
1343
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1344
|
+
// @ts-ignore
|
|
1345
|
+
sourceFileContentResponse.data.content,
|
|
1346
|
+
"base64"
|
|
1347
|
+
).toString("utf-8");
|
|
1348
|
+
const createTreeResponse = await oktoKit.rest.git.createTree({
|
|
1349
|
+
owner,
|
|
1350
|
+
repo,
|
|
1351
|
+
base_tree: await oktoKit.rest.git.getRef({ owner, repo, ref: `heads/${defaultBranch}` }).then((response) => response.data.object.sha),
|
|
1352
|
+
tree: [
|
|
1353
|
+
{
|
|
1354
|
+
path: targetFilePath,
|
|
1355
|
+
mode: "100644",
|
|
1356
|
+
type: "blob",
|
|
1357
|
+
content: decodedContent
|
|
1358
|
+
}
|
|
1359
|
+
]
|
|
1360
|
+
});
|
|
1361
|
+
const createCommitResponse = await oktoKit.rest.git.createCommit({
|
|
1362
|
+
owner,
|
|
1363
|
+
repo,
|
|
1364
|
+
message: "Add new yaml file",
|
|
1365
|
+
tree: createTreeResponse.data.sha,
|
|
1366
|
+
parents: [
|
|
1367
|
+
await oktoKit.rest.git.getRef({ owner, repo, ref: `heads/${defaultBranch}` }).then((response) => response.data.object.sha)
|
|
1368
|
+
]
|
|
1369
|
+
});
|
|
1370
|
+
await oktoKit.rest.git.updateRef({
|
|
1371
|
+
owner,
|
|
1372
|
+
repo,
|
|
1373
|
+
ref: `heads/${newBranchName}`,
|
|
1374
|
+
sha: createCommitResponse.data.sha
|
|
1375
|
+
});
|
|
1376
|
+
const createPRResponse = await oktoKit.rest.pulls.create({
|
|
1377
|
+
owner,
|
|
1378
|
+
repo,
|
|
1379
|
+
title,
|
|
1380
|
+
head: newBranchName,
|
|
1381
|
+
base: "main"
|
|
1382
|
+
});
|
|
1383
|
+
return {
|
|
1384
|
+
pull_request_url: createPRResponse.data.html_url
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1314
1387
|
|
|
1315
1388
|
// src/features/analysis/scm/github/consts.ts
|
|
1316
1389
|
var POST_COMMENT_PATH = "POST /repos/{owner}/{repo}/pulls/{pull_number}/comments";
|
|
@@ -1607,6 +1680,9 @@ var GitlabSCMLib = class extends SCMLib {
|
|
|
1607
1680
|
}
|
|
1608
1681
|
throw new Error("not supported yet");
|
|
1609
1682
|
}
|
|
1683
|
+
async createPullRequestWithNewFile(_sourceRepoUrl, _sourceFilePath, _targetFilePath, _userRepoUrl, _title) {
|
|
1684
|
+
throw new Error("not implemented");
|
|
1685
|
+
}
|
|
1610
1686
|
async getRepoList() {
|
|
1611
1687
|
if (!this.accessToken) {
|
|
1612
1688
|
console.error("no access token");
|
|
@@ -1791,6 +1867,21 @@ var GithubSCMLib = class extends SCMLib {
|
|
|
1791
1867
|
repo
|
|
1792
1868
|
});
|
|
1793
1869
|
}
|
|
1870
|
+
async createPullRequestWithNewFile(sourceRepoUrl, sourceFilePath, targetFilePath, userRepoUrl, title) {
|
|
1871
|
+
const { pull_request_url } = await createPr(
|
|
1872
|
+
{
|
|
1873
|
+
sourceRepoUrl,
|
|
1874
|
+
sourceFilePath,
|
|
1875
|
+
targetFilePath,
|
|
1876
|
+
userRepoUrl,
|
|
1877
|
+
title
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
githubAuthToken: this.accessToken
|
|
1881
|
+
}
|
|
1882
|
+
);
|
|
1883
|
+
return { pull_request_url };
|
|
1884
|
+
}
|
|
1794
1885
|
async validateParams() {
|
|
1795
1886
|
return githubValidateParams(this.url, this.accessToken);
|
|
1796
1887
|
}
|
|
@@ -2006,6 +2097,10 @@ var StubSCMLib = class extends SCMLib {
|
|
|
2006
2097
|
console.error("forkRepo() not implemented");
|
|
2007
2098
|
throw new Error("forkRepo() not implemented");
|
|
2008
2099
|
}
|
|
2100
|
+
async createPullRequestWithNewFile(_sourceRepoUrl, _sourceFilePath, _targetFilePath, _userRepoUrl, _title) {
|
|
2101
|
+
console.error("createPullRequestWithNewFile() not implemented");
|
|
2102
|
+
throw new Error("createPullRequestWithNewFile() not implemented");
|
|
2103
|
+
}
|
|
2009
2104
|
async getRepoList() {
|
|
2010
2105
|
console.error("getBranchList() not implemented");
|
|
2011
2106
|
throw new Error("getBranchList() not implemented");
|
|
@@ -3049,6 +3144,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
3049
3144
|
srcPath,
|
|
3050
3145
|
commitHash,
|
|
3051
3146
|
ref,
|
|
3147
|
+
experimentalEnabled,
|
|
3052
3148
|
scanner,
|
|
3053
3149
|
cxProjectName,
|
|
3054
3150
|
mobbProjectName,
|
|
@@ -3167,6 +3263,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
3167
3263
|
projectId,
|
|
3168
3264
|
vulnerabilityReportFileName: "report.json",
|
|
3169
3265
|
sha,
|
|
3266
|
+
experimentalEnabled,
|
|
3170
3267
|
pullRequest: params.pullRequest
|
|
3171
3268
|
});
|
|
3172
3269
|
if (sumbitRes.submitVulnerabilityReport.__typename !== "VulnerabilityReport") {
|
|
@@ -3412,6 +3509,7 @@ async function review(params, { skipPrompts = true } = {}) {
|
|
|
3412
3509
|
apiKey,
|
|
3413
3510
|
ci: true,
|
|
3414
3511
|
commitHash,
|
|
3512
|
+
experimentalEnabled: false,
|
|
3415
3513
|
mobbProjectName,
|
|
3416
3514
|
pullRequest,
|
|
3417
3515
|
githubToken,
|