Skip to content

NEW @W-22393691@ - sfap workspace scan#473

Merged
nikhil-mittal-165 merged 5 commits into
devfrom
feature/W-22393691-sfap-workspace-scan-v2
Jun 24, 2026
Merged

NEW @W-22393691@ - sfap workspace scan#473
nikhil-mittal-165 merged 5 commits into
devfrom
feature/W-22393691-sfap-workspace-scan-v2

Conversation

@nikhil-mittal-165

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for returning scan metadata (insights) from the ApexGuru engine through to the final output formats. It extends the API types to capture SFAP workspace scan metadata, adapts the service layer to parse and return this information, and enhances both JSON and SARIF formatters to include insights in their output.

GUS Ticket

W-22393691 — sfap workspace scan

Changes

  • ApexGuru Engine Types: Define ApexGuruScanMetadata type matching SFAP API contract with fields for workspace details, analysis info, and execution metadata
  • ApexGuru Service: Extend service to parse and return scan metadata from API responses; update all result types to include optional metadata
  • Engine Integration: Update ApexGuru engine to pass insights from service through to EngineRunResults
  • Engine API: Add optional insights field to EngineRunResults type to support arbitrary engine-specific metadata
  • Core Results: Add getInsights() and getEngineInsights() methods to results interfaces for accessing metadata
  • Output Formatters:
    • JSON formatter now includes insights array with engine-specific metadata
    • SARIF formatter includes insights in custom properties.insights field
  • Comprehensive Tests: Added test coverage for metadata extraction, type handling, and output serialization

Dependencies

None

Test Evidence

Unit tests added for:

  • ApexGuru metadata type validation and parsing
  • Service-level metadata extraction from API responses
  • Engine insights propagation through results chain
  • JSON and SARIF output format serialization of insights

Manual testing required:

  • Run workspace scan against SFAP-enabled org
  • Verify metadata appears in JSON output
  • Verify metadata appears in SARIF output

Test Status

Pending - awaiting unit test execution and manual validation

Findings Doc

Not applicable

@git2gus

git2gus Bot commented Jun 17, 2026

Copy link
Copy Markdown

Git2Gus App is installed but the .git2gus/config.json doesn't have right values. You should add the required configuration.

@nikhil-mittal-165 nikhil-mittal-165 marked this pull request as ready for review June 17, 2026 15:24
…n scanMetadata

- Define ApexGuruScanMetadata type matching SFAP API contract
- Extend ApexGuruService to parse and return scan metadata from API responses
- Update engine to pass insights through to results
- Add comprehensive tests for metadata extraction and type handling

feat(core): add insights to JSON and SARIF output formatters

- Add getInsights and getEngineInsights methods to results interfaces
- Enhance JSON output to include insights from engines
- Enhance SARIF output with custom insights property
- Add tests for insights serialization

feat(engine-api): add optional insights field to EngineRunResults type

- Allow engines to return structured metadata about scan execution
- Enables richer telemetry and debugging capabilities
@nikhil-mittal-165 nikhil-mittal-165 force-pushed the feature/W-22393691-sfap-workspace-scan-v2 branch from 9e20a60 to 3a28c37 Compare June 18, 2026 10:25
}

// Method 2: SF CLI default org (fallback)
this.emitLogEvent(LogLevel.Fine, 'No target org specified, using default org');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing these logs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restored

this.emitLogEvent(LogLevel.Fine, 'Successfully authenticated to default org');
} catch {
this.emitLogEvent(LogLevel.Error, 'Failed to authenticate: No default org found');
} catch (_err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include this as part of the debug logs? err is the actual exception and we are skipping it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

export type ApexGuruRequestBody = {
classContent: string; // Base64 encoded Apex class
};
export type ApexGuruScanMetadata = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: For the new JSDoc we can add documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"@salesforce/core": "^8.28.3"
"@salesforce/code-analyzer-engine-api": "0.39.0-SNAPSHOT",
"@salesforce/core": "^8.28.3",
"archiver": "^7.0.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure of the procedure to add new dependencies in the package. Is there any SOP we follow for doing this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have raised support tickets and also involved 3pp bot support here

https://salesforce-internal.slack.com/archives/C09R6E6BH8C/p1782101685635199

* - starts with "." (any dotfile/dotfolder, e.g. .sfdx, .git, .vscode)
* - is "node_modules" (npm dependencies — can be hundreds of MB and are not source code)
*/
function shouldExcludeFromZip(entryPath: string): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikhil-mittal-165 - Can this be an inclusive logic? Do we care for any other files other than Apex? If so, can we include only .cls and .trigger files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

const requestId = await this.submitAnalysis(classContent);
private async performScan(workspaceRoot: string, pathsToZip: string[]): Promise<{violations: ApexGuruViolation[], scanMetadata?: ApexGuruScanMetadata}> {
// Step 1: Create zip of workspace
const zipBuffer = await this.createWorkspaceZip(workspaceRoot, pathsToZip);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns about really large projects. Is there any limitation on the ApexGuru side?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have capped it to 20 mb currently, we can change this post apex guru comes back with their analysis

@nikhil-mittal-165 nikhil-mittal-165 merged commit 8c5b6cc into dev Jun 24, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants