Skip to content

Commit 2d12ca8

Browse files
abdeslamadsnvuillamechoixgithub-actions[bot]renovate[bot]
authored
upgrade code analyzer to v5 (#6386)
* upgrade code analyzer to v5 * change reference of sfdx-scanner dependency to code-analyzer * updated commands syntax to the new syntax of code-analyzer v5 * fix command argument per line issue * use new name of code-analyzer package name * Update salesforce.megalinter-descriptor.yml * Update salesforce.megalinter-descriptor.yml * [build-command] Update generated files * Update salesforce.megalinter-descriptor.yml * Update salesforce.megalinter-descriptor.yml * [build-command] Update generated files * Apply suggestion for renovate comment * [build-command] Update generated files * add code-analyzer as a new linter and keep sfdx-scanner * revise entrypoint and pyproject * Delete .eslintignore * revert changelog * move lightning flow scanner under sfdx scanner * fix one line per argument * [build-command] Update generated files * generate documenation for new linter (code-analyzer) * fix descriptor * modify regex for the test class * chore(deps): update dependency langchain_core to v1.0.7 [security] * chore(deps): update actions/checkout action to v6 * Handle more checkout action use cases * trvy * Add deprecations * trvy * fix: update Salesforce code analyzer configuration and references * test classes * fix * trvy * Updates Salesforce Code Analyzer to v5.6.1 Updates the Salesforce Code Analyzer to version 5.6.1 in all relevant files. This ensures that the latest rules and improvements are used during code analysis. It also updates the sfdx-hardis version. --------- Co-authored-by: Nicolas Vuillamy <nicolas.vuillamy@gmail.com> Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent f0b33e0 commit 2d12ca8

36 files changed

+3267
-654
lines changed

.automation/generated/linter-helps.json

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

.automation/generated/linter-links-previews.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@
8484
"image": "https://opengraph.githubassets.com/bf0d187aea6f03a804178458080b2be18a5fd1bf8d8cc353ff3150743aae9805/greglook/cljstyle",
8585
"title": "GitHub - greglook/cljstyle: A tool for formatting Clojure code"
8686
},
87+
"code-analyzer-apex": {
88+
"description": "To get started scanning your code with Salesforce Code Analyzer, follow this developer workflow and choose resources that match your learning style.",
89+
"image": null,
90+
"title": "Get Started | Salesforce Code Analyzer | Salesforce Developers"
91+
},
92+
"code-analyzer-aura": {
93+
"description": "To get started scanning your code with Salesforce Code Analyzer, follow this developer workflow and choose resources that match your learning style.",
94+
"image": null,
95+
"title": "Get Started | Salesforce Code Analyzer | Salesforce Developers"
96+
},
97+
"code-analyzer-lwc": {
98+
"description": "To get started scanning your code with Salesforce Code Analyzer, follow this developer workflow and choose resources that match your learning style.",
99+
"image": null,
100+
"title": "Get Started | Salesforce Code Analyzer | Salesforce Developers"
101+
},
87102
"coffeelint": {
88103
"description": "\n CoffeeLint is a style checker that helps keep\n CoffeeScript\n code clean and consistent. CoffeeScript does a great job at\n insulating programmers from many of\n JavaScript's bad parts, but it won't help enforce a consistent style\n across a code base. CoffeeLint can help with that.\n ",
89104
"image": null,

.automation/generated/linter-versions.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"clippy": "0.1.91",
1616
"clj-kondo": "2025.10.23",
1717
"cljstyle": "0.17.642",
18+
"code-analyzer-apex": "5.6.1",
19+
"code-analyzer-aura": "5.6.1",
20+
"code-analyzer-lwc": "5.6.1",
1821
"coffeelint": "5.2.11",
1922
"cppcheck": "2.14.2",
2023
"cpplint": "2.0.2",
@@ -33,7 +36,7 @@
3336
"eslint-plugin-jsonc": "2.15.1",
3437
"flake8": "7.3.0",
3538
"gherkin-lint": "0.0.0",
36-
"git_diff": "2.49.1",
39+
"git_diff": "2.47.0",
3740
"gitleaks": "8.28.0",
3841
"golangci-lint": "2.6.2",
3942
"goodcheck": "3.1.0",

.automation/generated/linters_matrix.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
"rst_rstfmt",
9595
"ruby_rubocop",
9696
"rust_clippy",
97+
"salesforce_code_analyzer_apex",
98+
"salesforce_code_analyzer_aura",
99+
"salesforce_code_analyzer_lwc",
97100
"salesforce_sfdx_scanner_apex",
98101
"salesforce_sfdx_scanner_aura",
99102
"salesforce_sfdx_scanner_lwc",

.automation/test/salesforce/bad/force-app/main/default/aura/auraIf/auraIfHelper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
({
22
convertValHlp : function(Val) {
3+
eval("console.log('using eval')");
34
if (Val === 'true')
45
return true ;
56
else

.automation/test/salesforce/bad/force-app/main/default/aura/auraIf2/auraIf2Helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
({
22
convertValHlp : function(Val) {
3+
eval("console.log('using eval')");
34
if (Val === 'true')
45
return true ;
56
else

.automation/test/salesforce/bad/force-app/main/default/lwc/stockTable/stockTable.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,46 @@ export default class StockTable extends LightningElement {
6666
sortedBy;
6767
maxRows = DEFAULT_END_ARRAY;
6868

69+
// HIGH: @lwc/lwc/no-async-operation - Async operation in connectedCallback
70+
connectedCallback() {
71+
setTimeout(() => {
72+
this.loadData();
73+
}, 1000);
74+
75+
setInterval(() => {
76+
console.log('Polling data...');
77+
}, 5000);
78+
}
79+
80+
// HIGH: @lwc/lwc/no-document-query - Direct DOM manipulation
81+
// HIGH: @lwc/lwc/no-inner-html - Using innerHTML
82+
loadData() {
83+
const element = document.querySelector('.stock-table');
84+
if (element) {
85+
element.innerHTML = '<div>Loading...</div>';
86+
}
87+
88+
const div = this.template.querySelector('div');
89+
if (div) {
90+
div.innerHTML = '<span>Unsafe content</span>';
91+
}
92+
}
93+
6994
handleChangeDisplay(event) {
7095
this.maxRows = event.detail.pageSize;
7196
this.setStocksToDisplay(event.detail);
97+
98+
// HIGH: @lwc/lwc/no-api-reassignments - Reassigning @api property
99+
this.stocks = [];
72100
}
73101

74102
setStocksToDisplay({ start = DEFAULT_START_ARRAY, end = this.maxRows } = {}) {
75103
if (this._stocks) {
76104
console.log(`START : ${start} ==== END : ${end}`);
77105
this.stocksToDisplay = this._stocks.slice(start, end);
106+
107+
// HIGH: @lwc/lwc/no-leading-uppercase-api-name - Invalid API property name
108+
this.ApiData = this.stocksToDisplay;
78109
}
79110
}
80111

@@ -88,10 +119,20 @@ export default class StockTable extends LightningElement {
88119

89120
this._stocks = cloneData;
90121
this.setStocksToDisplay();
91-
this.template.querySelector("c-stock-paginator").setPagesAttributes();
92-
this.template.querySelector("c-stock-paginator").setControlClass();
122+
123+
// HIGH: @lwc/lwc/no-async-operation - Using setTimeout in event handler
124+
setTimeout(() => {
125+
this.template.querySelector("c-stock-paginator").setPagesAttributes();
126+
this.template.querySelector("c-stock-paginator").setControlClass();
127+
}, 100);
128+
93129
this.sortedBy = sortedBy;
94130
this.sortDirection = sortDirection;
131+
132+
// HIGH: @lwc/lwc/no-restricted-browser-globals-during-ssr - Using window object
133+
if (window.location.href.includes('stock')) {
134+
console.log('Stock page');
135+
}
95136
}
96137

97138
sortBy(field, sortDirection) {
@@ -102,7 +143,7 @@ export default class StockTable extends LightningElement {
102143
let aKey = key(a);
103144
let bKey = key(b);
104145

105-
if (typeof a = "string") {
146+
if (typeof a == "string") {
106147
aKey = aKey.toUpperCase();
107148
bKey = bKey.toUpperCase();
108149
}

.automation/test/salesforce/bad/force-app/main/default/lwc/stockTable2/stockTable2.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ export default class StockTable extends LightningElement {
6666
sortedBy;
6767
maxRows = DEFAULT_END_ARRAY;
6868

69+
// HIGH: @lwc/lwc/no-async-operation - Async operation in connectedCallback
70+
connectedCallback() {
71+
setTimeout(() => {
72+
this.initializeTable();
73+
}, 500);
74+
}
75+
76+
// HIGH: @lwc/lwc/no-document-query - Direct DOM query
77+
initializeTable() {
78+
const tableEl = document.getElementById('stock-table');
79+
if (tableEl) {
80+
tableEl.classList.add('initialized');
81+
}
82+
}
83+
6984
handleChangeDisplay(event) {
7085
this.maxRows = event.detail.pageSize;
7186
this.setStocksToDisplay(event.detail);
@@ -92,6 +107,9 @@ export default class StockTable extends LightningElement {
92107
this.template.querySelector("c-stock-paginator").setControlClass();
93108
this.sortedBy = sortedBy;
94109
this.sortDirection = sortDirection;
110+
111+
// HIGH: Using document directly
112+
document.title = 'Stock Table Sorted';
95113
}
96114

97115
sortBy(field, sortDirection) {
@@ -102,7 +120,7 @@ export default class StockTable extends LightningElement {
102120
let aKey = key(a);
103121
let bKey = key(b);
104122

105-
if (typeof a = "string") {
123+
if (typeof a == "string") {
106124
aKey = aKey.toUpperCase();
107125
bKey = bKey.toUpperCase();
108126
}

.trivyignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ CVE-2025-48734
9191
CVE-2025-55163
9292
# Remove when migrated to code-analyzer
9393
CVE-2025-59419
94+
CVE-2025-64756
9495

9596
# octokit
9697
CVE-2025-25288
@@ -161,6 +162,8 @@ CVE-2025-9288
161162
CVE-2025-64118
162163
# https://avd.aquasec.com/nvd/cve-2025-65106 : Langchain core vulnerable to prompt injection. As prompts are built only by MegaLinter or local overrides in the repo, this is harmless
163164
CVE-2025-65106
165+
# https://avd.aquasec.com/nvd/cve-2025-64756 : Glob command injection. Harmless in MegaLinter context as user inputs are not passed to glob patterns
166+
CVE-2025-64756
164167
# Dockerfile
165168
DS001
166169
DS002

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ ARG GEM_RUBOCOP_RAILS_VERSION=2.34.0
340340
ARG GEM_RUBOCOP_RAKE_VERSION=0.7.1
341341
# renovate: datasource=rubygems depName=rubocop-rspec
342342
ARG GEM_RUBOCOP_RSPEC_VERSION=3.8.0
343+
# renovate: datasource=npm depName=@salesforce/plugin-code-analyzer
344+
ARG SALESFORCE_CODE_ANALYZER_VERSION=5.6.1
343345
# renovate: datasource=npm depName=@salesforce/sfdx-scanner
344346
ARG SALESFORCE_SFDX_SCANNER_VERSION=4.12.0
345347
# renovate: datasource=pypi depName=snakemake
@@ -1097,6 +1099,23 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/refs/tags/v${REPOS
10971099
#
10981100
# rubocop installation
10991101
#
1102+
# code-analyzer-apex installation
1103+
&& sf plugins install code-analyzer@${SALESFORCE_CODE_ANALYZER_VERSION} \
1104+
&& (npm cache clean --force || true) \
1105+
&& rm -rf /root/.npm/_cacache \
1106+
#
1107+
# code-analyzer-aura installation
1108+
# Next line commented because already managed by another linter
1109+
# RUN sf plugins install code-analyzer@${SALESFORCE_CODE_ANALYZER_VERSION} \
1110+
# && (npm cache clean --force || true) \
1111+
# && rm -rf /root/.npm/_cacache
1112+
#
1113+
# code-analyzer-lwc installation
1114+
# Next line commented because already managed by another linter
1115+
# RUN sf plugins install code-analyzer@${SALESFORCE_CODE_ANALYZER_VERSION} \
1116+
# && (npm cache clean --force || true) \
1117+
# && rm -rf /root/.npm/_cacache
1118+
#
11001119
# sfdx-scanner-apex installation
11011120
&& sf plugins install @salesforce/sfdx-scanner@${SALESFORCE_SFDX_SCANNER_VERSION} \
11021121
&& (npm cache clean --force || true) \

0 commit comments

Comments
 (0)