Skip to content

Commit 7f7d6da

Browse files
committed
scans v2 integration
1 parent 57ff16d commit 7f7d6da

8 files changed

Lines changed: 633 additions & 3 deletions

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
".": "./src/reviewHeadless.js",
2828
"./review": "./src/reviewHeadless.js",
2929
"./push-protection": "./src/utils/installPushProtectionHook.js",
30-
"./config": "./src/utils/config.js"
30+
"./config": "./src/utils/config.js",
31+
"./scans/connection": "./src/scans/connectionHandler.js",
32+
"./scans/list-repos": "./src/scans/listRepos.js",
33+
"./scans/scan-history": "./src/scans/getScanHistory.js",
34+
"./scans/fetch-results": "./src/scans/fetchScanResults.js",
35+
"./scans/fetch-advanced-results": "./src/scans/fetchAdvancedScanResults.js",
36+
"./scans/dismissed-alerts": "./src/scans/fetchDismissedAlerts.js"
3137
},
3238
"files": [
3339
"src"

‎src/scans/connectionHandler.js‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { fetchApi } from '../utils/fetchApi.js';
2+
3+
/**
4+
* Validate the stored API key with the CodeAnt backend.
5+
*
6+
* @returns {Promise<Object>}
7+
* {
8+
* success: true,
9+
* connections: [
10+
* {
11+
* organizationName: "acme-corp",
12+
* baseUrl: "https://github.com",
13+
* service: "github" | "gitlab" | "azuredevops" | "bitbucket" | "unknown"
14+
* }
15+
* ],
16+
* email: "dev@acme.com",
17+
* }
18+
*/
19+
export async function validateConnection() {
20+
try {
21+
const response = await fetchApi('/extension/scans2/validate', 'POST', {
22+
extension: 'cli',
23+
});
24+
25+
if (!response) {
26+
return { success: false, error: 'Failed to connect to CodeAnt server' };
27+
}
28+
29+
if (response.status === 'success' && response.data) {
30+
const orgs = response.data.orgs || [];
31+
return {
32+
success: true,
33+
connections: orgs.map((org) => ({
34+
organizationName: org.organization_name,
35+
baseUrl: org.base_url,
36+
service: org.service || 'unknown',
37+
})),
38+
email: response.data.email,
39+
};
40+
}
41+
42+
return {
43+
success: false,
44+
error: response.message || 'Invalid or expired connection string',
45+
};
46+
} catch (error) {
47+
return {
48+
success: false,
49+
error: error.message || 'Failed to validate connection string',
50+
};
51+
}
52+
}

0 commit comments

Comments
 (0)