Skip to content

Commit 2c34ba5

Browse files
authored
Merge pull request #1206 from forcedotcom/dev
RELEASE: @W-14198233@: Merging dev to release for v3.17.0
2 parents b6bd5f6 + ca911e5 commit 2c34ba5

File tree

12 files changed

+174
-77
lines changed

12 files changed

+174
-77
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@salesforce/sfdx-scanner",
33
"description": "Static code scanner that applies quality and security rules to Apex code, and provides feedback.",
4-
"version": "3.16.0",
4+
"version": "3.17.0",
55
"author": "ISV SWAT",
66
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
77
"dependencies": {

retire-js/RetireJsVulns.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
},
408408
{
409409
"below": "1.19.3",
410-
"severity": "medium",
410+
"severity": "high",
411411
"cwe": [
412412
"CWE-400"
413413
],
@@ -2812,7 +2812,7 @@
28122812
"vulnerabilities": [
28132813
{
28142814
"below": "0.5.0",
2815-
"severity": "high",
2815+
"severity": "medium",
28162816
"cwe": [
28172817
"CWE-79"
28182818
],
@@ -3555,7 +3555,7 @@
35553555
},
35563556
{
35573557
"below": "2.0.3",
3558-
"severity": "high",
3558+
"severity": "medium",
35593559
"cwe": [
35603560
"CWE-79"
35613561
],

sfge/src/main/java/com/salesforce/rules/PerformNullCheckOnSoqlVariables.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ protected boolean isEnabled() {
6262
return true;
6363
}
6464

65+
@Override
66+
protected boolean isPilot() {
67+
return false;
68+
}
69+
6570
/**
6671
* Tests a vertex using a symbol provider to check if it violates this rule.
6772
*

src/lib/formatter/RuleResultRecombinator.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ export class RuleResultRecombinator {
110110
private static constructXml(results: RuleResult[]): string {
111111
let resultXml = ``;
112112

113-
// If the results were just an empty string, we can return it.
114-
if (results.length === 0) {
115-
return resultXml;
116-
}
117-
118-
const normalizeSeverity: boolean = results[0].violations.length > 0 && !(results[0].violations[0].normalizedSeverity === undefined)
113+
const normalizeSeverity: boolean = results[0]?.violations.length > 0 && !(results[0]?.violations[0].normalizedSeverity === undefined)
119114

120115
let problemCount = 0;
121116

@@ -188,10 +183,6 @@ export class RuleResultRecombinator {
188183
}
189184

190185
private static constructJunit(results: RuleResult[]): string {
191-
// If there are no results, we can just return an empty string.
192-
if (!results || results.length === 0) {
193-
return '';
194-
}
195186

196187
// Otherwise, we'll need to start constructing our JUnit XML. To do that, we'll need a map from file names to
197188
// lists of the <failure> tags generated from violations found in the corresponding file.
@@ -279,10 +270,6 @@ URL: ${url}`;
279270
}
280271

281272
private static constructTable(results: RuleResult[]): RecombinedData {
282-
// If the results were just an empty string, we can return it.
283-
if (results.length === 0) {
284-
return '';
285-
}
286273
const columns = this.violationsAreDfa(results)
287274
? ['Source Location', 'Sink Location', 'Description', 'Category', 'URL']
288275
: ['Location', 'Description', 'Category', 'URL'];
@@ -341,10 +328,6 @@ URL: ${url}`;
341328
}
342329

343330
private static constructJson(results: RuleResult[], verboseViolations = false): string {
344-
if (results.length === 0) {
345-
return '';
346-
}
347-
348331
if (verboseViolations) {
349332
const resultsVerbose = JSON.parse(JSON.stringify(results)) as RuleResult[];
350333
for (const result of resultsVerbose) {
@@ -363,12 +346,7 @@ URL: ${url}`;
363346
}
364347

365348
private static async constructHtml(results: RuleResult[], verboseViolations = false): Promise<string> {
366-
// If the results were just an empty string, we can return it.
367-
if (results.length === 0) {
368-
return '';
369-
}
370-
371-
const normalizeSeverity: boolean = results[0].violations.length > 0 && !(results[0].violations[0].normalizedSeverity === undefined);
349+
const normalizeSeverity: boolean = results[0]?.violations.length > 0 && !(results[0]?.violations[0].normalizedSeverity === undefined);
372350
const isDfa = this.violationsAreDfa(results);
373351

374352

@@ -434,12 +412,8 @@ URL: ${url}`;
434412
}
435413

436414
private static async constructCsv(results: RuleResult[]): Promise<string> {
437-
// If the results were just an empty list, we can return an empty string
438-
if (results.length === 0) {
439-
return '';
440-
}
441415
const isDfa: boolean = this.violationsAreDfa(results);
442-
const normalizeSeverity: boolean = results[0].violations.length > 0 && !(results[0].violations[0].normalizedSeverity === undefined)
416+
const normalizeSeverity: boolean = results[0]?.violations.length > 0 && !(results[0]?.violations[0].normalizedSeverity === undefined)
443417

444418
const csvRows = [];
445419
// There will always be columns for the problem counter and the severity.

src/lib/util/Config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const DEFAULT_CONFIG: ConfigContent = {
3737
name: ENGINE.PMD,
3838
targetPatterns: [
3939
"**/*.cls","**/*.trigger","**/*.java","**/*.page","**/*.component","**/*.xml",
40-
"!**/node_modules/**","!**/*-meta.xml"
40+
"!**/node_modules/**"
4141
],
4242
supportedLanguages: ['apex', 'vf'],
4343
disabled: false

src/lib/util/RunOutputProcessor.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,27 @@ export class RunOutputProcessor {
2828

2929

3030
public processRunOutput(rrr: RecombinedRuleResults): AnyJson {
31-
const {minSev, summaryMap, results} = rrr;
32-
// If the results are an empty string, it means no violations were found.
33-
if (results === '') {
34-
// Build an appropriate message...
31+
const {minSev, results, summaryMap} = rrr;
32+
33+
const hasViolations = [...summaryMap.values()].some(summary => summary.violationCount !== 0);
34+
35+
// If there are neither violations nor an outfile, then we want to avoid writing empty
36+
// results to the console.
37+
// NOTE: If there's an outfile, we skip this part. This is because we still want to generate
38+
// an empty outfile
39+
if (!this.opts.outfile && !hasViolations) {
40+
// Build a message indicating which engines were run...
3541
const msg = messages.getMessage('output.noViolationsDetected', [[...summaryMap.keys()].join(', ')]);
3642
// ...log it to the console...
3743
this.ux.log(msg);
3844
// ...and return it for use with the --json flag.
3945
return msg;
4046
}
4147

42-
// If we actually have violations, there's some stuff we need to do with them. We'll build an array of message parts,
43-
// and then log them all at the end.
48+
// If we have violations (or an outfile but no violations), we'll build an array of
49+
// message parts, and then log them all at the end.
4450
let msgComponents: string[] = [];
45-
// We need a summary of the information we were provided.
51+
// We need a summary of the information we were provided (blank/empty if no violations).
4652
msgComponents = [...msgComponents, ...this.buildRunSummaryMsgParts(rrr)];
4753
// We need to surface the results directly to the user, then add a message describing what we did.
4854
msgComponents.push(this.opts.outfile ? this.writeToOutfile(results) : this.writeToConsole(results));

src/lib/util/VersionUpgradeManager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ upgradeScriptsByVersion.set('v2.7.0', (config: ConfigContent): Promise<void> =>
3838
return Promise.resolve();
3939
});
4040
upgradeScriptsByVersion.set('v3.0.0', (config: ConfigContent): Promise<void> => {
41-
// In v3.0.0, we're changing RetireJS from a supplemental engine that must be manually enabled to an enabled-byu-default
41+
// In v3.0.0, we're changing RetireJS from a supplemental engine that must be manually enabled to an enabled-by-default
4242
// engine. So we need to change its `disabled` config value from true to false.
4343
const retireJsConfig: EngineConfigContent = config.engines.find(e => e.name === ENGINE.RETIRE_JS);
4444
if (retireJsConfig) {
@@ -63,6 +63,16 @@ upgradeScriptsByVersion.set('v3.6.0', async (config: ConfigContent): Promise<voi
6363
}
6464
}
6565
});
66+
upgradeScriptsByVersion.set('v3.17.0', (config: ConfigContent): Promise<void> => {
67+
// In v3.17.0, we're changing PMD's config so that it no longer excludes Salesforce metadata
68+
// files by default. This will automatically apply to any newly-generated configs, but we also
69+
// want to retroactively remove this exclusion for existing users.
70+
const pmdConfig: EngineConfigContent = config.engines.find(e => e.name === ENGINE.PMD);
71+
if (pmdConfig) {
72+
pmdConfig.targetPatterns = pmdConfig.targetPatterns.filter(s => s !== '!**/*-meta.xml');
73+
}
74+
return Promise.resolve();
75+
});
6676

6777

6878
// ================ CLASSES =====================

test/commands/scanner/run.filters.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ describe('scanner:run tests that result in the use of RuleFilters', function ()
1919
'--engine', 'eslint-lwc'
2020
])
2121
.it('LWC Engine Successfully parses LWC code', ctx => {
22-
expect(ctx.stdout).to.contain('No rule violations found.');
22+
// If there's a summary, then it'll be separated from the CSV by an empty line. Throw it away.
23+
const [csv, _] = ctx.stdout.trim().split(/\n\r?\n/);
24+
25+
// Confirm there are no violations.
26+
// Since it's a CSV, the rows themselves are separated by newline characters.
27+
// The header should not have any newline characters after it. There should be no violation rows.
28+
expect(csv.indexOf('\n')).to.equal(-1, "Should be no violations detected");
2329
});
2430

2531
setupCommandTest

0 commit comments

Comments
 (0)