Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a563c7a
Handle method invocations made directly on iterated array item
rmohan20 Apr 28, 2023
d1810c6
Minor cleanup
rmohan20 Apr 28, 2023
dabd867
Restore test util
rmohan20 Apr 28, 2023
7392501
Outline of GGD in loop rule
rmohan20 Apr 17, 2023
432d5a7
Basics + tests before changing violation generation
rmohan20 Apr 19, 2023
33d27c7
Fixing asserts on tests, adding more rule scenarios
rmohan20 Apr 20, 2023
905f2e4
Renaming to MultipleMassSchemaLookupRule
rmohan20 Apr 21, 2023
d21844a
Renames to match updated rule name
rmohan20 Apr 25, 2023
4a48ffc
Fixing NPE on comparator issue
rmohan20 May 2, 2023
0946b07
Applying UI text changes + minor renames
rmohan20 May 3, 2023
81eb5d3
Enabling MMSLookupRule + format fixes
rmohan20 May 3, 2023
3b1b738
Minor cleanup
rmohan20 May 4, 2023
018b280
Merge branch 'dev' into rm/arrayBasedForLoop
rmohan20 May 4, 2023
29ec2dd
Merge pull request #1062 from forcedotcom/rm/arrayBasedForLoop
rmohan20 May 4, 2023
8524450
Feedback items. Loop exit detection not included
rmohan20 May 4, 2023
3c556cc
Merge branch 'dev' into rm/ggdInLoop1
rmohan20 May 4, 2023
6bba121
Merge pull request #1054 from forcedotcom/rm/ggdInLoop1
rmohan20 May 4, 2023
3d43842
@W-13136274@: Sources are now specified at the rule level.
jfeingold35 May 2, 2023
48c544b
@W-13136274@: Integrated feedback from code review.
jfeingold35 May 4, 2023
2a1e0a8
@W-13136274@: Implemented getSourceTypes for MultipleMassSchemaLookup…
jfeingold35 May 5, 2023
fd8d06e
Merge pull request #1068 from forcedotcom/d/W-13136274
jfeingold35 May 5, 2023
e2732ba
@W-13080871@: Triggers are now compiled and added to the graph.
jfeingold35 May 4, 2023
51fa73a
Merge pull request #1072 from forcedotcom/d/W-13080871-b
jfeingold35 May 16, 2023
98bcd7c
@W-13151459@: IOC initializes in scanner command instead of OCLIF.
jfeingold35 May 12, 2023
c50e9d3
Merge pull request #1073 from forcedotcom/d/W-13151459
jfeingold35 May 16, 2023
23772e1
Bump vm2 from 3.9.17 to 3.9.19
dependabot[bot] May 16, 2023
fc6ca27
@W-12672062@: Add support for built-in String method substringAfterLast.
jfeingold35 May 12, 2023
91efc49
Merge pull request #1074 from forcedotcom/d/W-12672062
jfeingold35 May 17, 2023
3c11d77
Adding loop boundaries while walking the path
rmohan20 May 18, 2023
a7f80aa
Formatting changes + renames
rmohan20 May 18, 2023
e1b36dd
Additional documentation
rmohan20 May 18, 2023
12023d2
Reformatted doc
rmohan20 May 18, 2023
61faa1d
Enable MultipleMassSchemaLookupRule in pilot mode
rmohan20 May 18, 2023
39c9086
Update rule count in tests
rmohan20 May 18, 2023
c3ef7d8
Merge pull request #1078 from forcedotcom/rm/loopscope
jfeingold35 May 18, 2023
6cbc714
Updated apex-jorje-lsp jar with minor test changes
rmohan20 May 19, 2023
1533b09
Merge pull request #1079 from forcedotcom/rm/new-jorje-jar
jfeingold35 May 19, 2023
3581249
Parse user mode and system mode on DML operations. Exclude user mode …
rmohan20 May 19, 2023
51a208f
Fixing AST format in comments
rmohan20 May 19, 2023
37be296
Merge pull request #1080 from forcedotcom/rm/dmlAsUser
rmohan20 May 19, 2023
000d3b4
FIX (CodeAnalyzer): @W-13473580@: Pmd output now treats position info…
jfeingold35 May 23, 2023
671e544
Merge pull request #1081 from forcedotcom/d/W-13473580
jfeingold35 May 24, 2023
95bd40e
Exclude method calls from ForEach loop definition in MMSLookupRule
rmohan20 May 25, 2023
d2eaf85
Merge pull request #1082 from forcedotcom/rm/forEachMethodCall
rmohan20 May 25, 2023
0aee19e
Filling gaps in loop exclusion
rmohan20 May 31, 2023
b0c5ee8
Fixing a broken test
rmohan20 May 31, 2023
d5f3573
Merge pull request #1084 from forcedotcom/rm/MMSRuleMethodIndirection
rmohan20 May 31, 2023
fcb5e99
Merge branch 'dev' into dependabot/npm_and_yarn/vm2-3.9.19
rmohan20 Jun 1, 2023
253c692
Fix to handle loop exclusions more effectively
rmohan20 Jun 2, 2023
5179ff0
Applying PR feedback
rmohan20 Jun 2, 2023
a20b2b6
Merge pull request #1076 from forcedotcom/dependabot/npm_and_yarn/vm2…
rmohan20 Jun 2, 2023
32ee53e
Merge branch 'dev' into rm/fixNestedLoopMMSLR
rmohan20 Jun 2, 2023
ce8880c
Merge pull request #1085 from forcedotcom/rm/fixNestedLoopMMSLR
rmohan20 Jun 2, 2023
bb7920b
Updating release version + retireJS changes
rmohan20 Jun 5, 2023
f267158
Merge pull request #1088 from forcedotcom/rm/3.13-activities
rmohan20 Jun 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/sfdx-scanner",
"description": "Static code scanner that applies quality and security rules to Apex code, and provides feedback.",
"version": "3.12.0",
"version": "3.13.0",
"author": "ISV SWAT",
"bugs": "https://github.com/forcedotcom/sfdx-scanner/issues",
"dependencies": {
Expand Down Expand Up @@ -119,10 +119,7 @@
},
"devPlugins": [
"@oclif/plugin-help"
],
"hooks": {
"init": "./lib/lib/hooks/init"
}
]
},
"nyc": {
"branches": "80",
Expand Down
138 changes: 137 additions & 1 deletion retire-js/RetireJsVulns.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@
"jquery-ui",
"jquery.ui"
],
"npmname": "jquery-ui",
"vulnerabilities": [
{
"below": "1.13.2",
Expand Down Expand Up @@ -671,6 +672,7 @@
"jquery-ui",
"jquery.ui"
],
"npmname": "jquery-ui",
"vulnerabilities": [
{
"atOrAbove": "1.8.9",
Expand Down Expand Up @@ -728,6 +730,7 @@
"jquery-ui",
"jquery.ui"
],
"npmname": "jquery-ui",
"vulnerabilities": [],
"extractors": {
"filecontent": [
Expand All @@ -744,6 +747,7 @@
"jquery-ui",
"jquery.ui"
],
"npmname": "jquery-ui",
"vulnerabilities": [
{
"atOrAbove": "1.9.2",
Expand Down Expand Up @@ -779,6 +783,7 @@
"bowername": [
"jquery-prettyPhoto"
],
"basePurl": "pkg:github/scaron/prettyphoto",
"vulnerabilities": [
{
"below": "3.1.5",
Expand Down Expand Up @@ -826,6 +831,7 @@
"bowername": [
"jPlayer"
],
"npmname": "jplayer",
"vulnerabilities": [
{
"below": "2.3.1",
Expand Down Expand Up @@ -987,6 +993,7 @@
"tinymce",
"tinymce-dist"
],
"npmname": "tinymce",
"vulnerabilities": [
{
"below": "1.4.2",
Expand Down Expand Up @@ -1196,6 +1203,7 @@
"yui",
"yui3"
],
"npmname": "yui",
"vulnerabilities": [
{
"atOrAbove": "3.5.0",
Expand Down Expand Up @@ -2307,6 +2315,7 @@
"angularjs",
"angular.js"
],
"npmname": "angular",
"vulnerabilities": [
{
"below": "1.8.0",
Expand Down Expand Up @@ -2496,6 +2505,8 @@
"backbonejs",
"backbone"
],
"npmname": "backbone",
"basePurl": "npm:npm/backbone",
"vulnerabilities": [
{
"below": "0.5.0",
Expand Down Expand Up @@ -2532,6 +2543,8 @@
"mustache.js",
"mustache"
],
"npmname": "mustache",
"basePurl": "npm:npm/mustache",
"vulnerabilities": [
{
"below": "0.3.1",
Expand Down Expand Up @@ -2925,6 +2938,7 @@
}
},
"easyXDM": {
"npmname": "easyxdm",
"vulnerabilities": [
{
"below": "2.4.18",
Expand Down Expand Up @@ -3166,6 +3180,7 @@
"dompurify",
"DOMPurify"
],
"npmname": "dompurify",
"vulnerabilities": [
{
"below": "0.6.1",
Expand Down Expand Up @@ -3514,6 +3529,7 @@
}
},
"DWR": {
"npmname": "dwr",
"vulnerabilities": [
{
"below": "1.1.4",
Expand Down Expand Up @@ -3578,6 +3594,8 @@
"moment",
"momentjs"
],
"npmname": "moment",
"basePurl": "pkg:npm/moment",
"vulnerabilities": [
{
"below": "2.11.2",
Expand Down Expand Up @@ -3664,8 +3682,11 @@
"uri": [
"/moment\\.js/(§§version§§)/moment(.min)?\\.js"
],
"filename": [
"moment(?:-|\\.)(§§version§§)(?:-min)?\\.js"
],
"filecontent": [
"//! moment.js(?:[\n\r]+)//! version : (§§version§§)",
"//!? moment.js(?:[\n\r]+)//!? version : (§§version§§)",
"\\.version=\"(§§version§§)\".{300,500}\\.isMoment="
]
}
Expand All @@ -3675,6 +3696,7 @@
"Underscore",
"underscore"
],
"npmname": "underscore",
"vulnerabilities": [
{
"below": "1.12.1",
Expand Down Expand Up @@ -4726,6 +4748,7 @@
}
},
"AlaSQL": {
"npmname": "alasql",
"vulnerabilities": [
{
"below": "0.7.0",
Expand Down Expand Up @@ -4755,6 +4778,7 @@
}
},
"jquery.datatables": {
"npmname": "datatables",
"vulnerabilities": [
{
"below": "1.11.3",
Expand Down Expand Up @@ -5009,6 +5033,118 @@
]
}
},
"froala": {
"npmname": "froala-editor",
"vulnerabilities": [
{
"below": "4.0.11",
"severity": "medium",
"cwe": [
"CWE-79"
],
"identifiers": {
"summary": "XSS vulnerability in [insert video]",
"issue": "3880"
},
"info": [
"https://github.com/froala/wysiwyg-editor/releases/tag/v4.0.11"
]
},
{
"below": "3.2.7",
"severity": "high",
"cwe": [
"CWE-79"
],
"identifiers": {
"summary": "Froala WYSIWYG Editor 3.2.6-1 is affected by XSS due to a namespace confusion during parsing.",
"CVE": [
"CVE-2021-28114"
]
},
"info": [
"https://bishopfox.com/blog/froala-editor-v3-2-6-advisory"
]
},
{
"below": "3.2.7",
"severity": "medium",
"cwe": [
"CWE-79"
],
"identifiers": {
"summary": "Froala WYSIWYG Editor 3.2.6 is affected by Cross Site Scripting (XSS). Under certain conditions, a base64 crafted string leads to persistent XSS.",
"CVE": [
"CVE-2021-30109"
]
},
"info": [
"https://github.com/froala/wysiwyg-editor/releases/tag/v4.0.11"
]
},
{
"below": "3.2.2",
"severity": "medium",
"cwe": [
"CWE-79"
],
"identifiers": {
"summary": "Security issue: XSS via pasted content",
"issue": "3880"
},
"info": [
"https://froala.com/wysiwyg-editor/changelog/#3.2.2"
]
},
{
"below": "3.2.2",
"severity": "medium",
"cwe": [
"CWE-79"
],
"identifiers": {
"summary": "XSS Issue In Link Insertion",
"issue": "3270"
},
"info": [
"https://github.com/froala/wysiwyg-editor/issues/3270"
]
}
],
"extractors": {
"uri": [
"/froala-editor/(§§version§§)/",
"/froala-editor@(§§version§§)/"
],
"filecontent": [
"/\\*![\\s]+\\* froala_editor v(§§version§§)",
"VERSION:\"(§§version§§)\",INSTANCES:\\[\\],OPTS_MAPPING:\\{\\}"
]
}
},
"pendo": {
"vulnerabilities": [
{
"below": "2.15.18",
"severity": "medium",
"cwe": [
"CWE-79"
],
"identifiers": {
"summary": "Patched XSS vulnerability around script loading",
"retid": "74"
},
"info": [
"https://developers.pendo.io/agent-version-2-15-18/"
]
}
],
"extractors": {
"filecontent": [
"// Pendo Agent Wrapper\n//[\\s]+Environment:[\\s]+[^\n]+\n// Agent Version:[\\s]+(§§version§§)"
]
}
},
"dont check": {
"extractors": {
"uri": [
Expand Down
Binary file modified sfge/lib/apex-jorje-lsp-sfge.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public void accept(JorjeNodeVisitor visitor) {
@Override
protected void fillProperties(Map<String, Object> properties) {
properties.put(Schema.NAME, getName());
properties.put(Schema.TARGET_NAME, getNode().getTargetName().get(0).getValue());
properties.put(Schema.USAGES, getNode().getUsages().toString());
}
}
22 changes: 16 additions & 6 deletions sfge/src/main/java/com/salesforce/collections/CollectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
import com.google.common.collect.ImmutableList;
import com.salesforce.exception.UnexpectedException;
import com.salesforce.graph.ops.TypeableUtil;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -186,5 +181,20 @@ public static <T, U> List<U> newImmutableListOf(
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
}

/**
* Peek into the stack to get the last element. Converts value into an Optional instead of
* throwing an {@link EmptyStackException} when stack is empty.
*
* @param stack to look at
* @param <T> Stack's generic
* @return last element added to the stack
*/
public static <T> Optional<T> peek(Stack<T> stack) {
if (stack.isEmpty()) {
return Optional.empty();
}
return Optional.of(stack.peek());
}

private CollectionUtil() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public final class UserFacingMessages {

public static final class RuleDescriptions {
public static final String APEX_NULL_POINTER_EXCEPTION_RULE =
"Identfies Apex operations that dereference null objects and throw NullPointerExceptions.";
"Identifies Apex operations that dereference null objects and throw NullPointerExceptions.";
public static final String UNIMPLEMENTED_TYPE_RULE =
"Identifies abstract classes and interfaces that are non-global and don't have implementations or extensions.";
public static final String UNUSED_METHOD_RULE =
"Identifies methods that aren't invoked from recognized entry points.";
public static final String MULTIPLE_MASS_SCHEMA_LOOKUP_RULE =
"Detects mass schema lookups that can cause performance degradation if made more than once in a path. These methods are: Schema.getGlobalDescribe() and Schema.describeSObjects(...). Flagged lookups include those within a loop or multiple invocations in a path.";
}

public static final class RuleViolationTemplates {
Expand Down Expand Up @@ -75,4 +77,10 @@ public static final class CompilationErrors {
"Graph engine encountered compilation errors. Fix the errors in %s and retry.";
public static final String EXCEPTION_FORMAT_TEMPLATE = "%s, Caused by:\n%s";
}

public static final class MultipleMassSchemaLookupRuleTemplates {
public static final String MESSAGE_TEMPLATE = "%s was %s at %s:%d.";
public static final String OCCURRENCE_LOOP_TEMPLATE = "called inside a %s";
public static final String OCCURRENCE_MULTIPLE_TEMPLATE = "preceded by a call to %s";
}
}
2 changes: 2 additions & 0 deletions sfge/src/main/java/com/salesforce/graph/Schema.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ public class Schema {
public static final String STATIC_CONSTRUCTOR_CANONICAL_NAME = "<clinit>";
public static final String SUPER_CLASS_NAME = "SuperClassName";
public static final String SUPER_INTERFACE_NAME = "SuperInterfaceName";
public static final String TARGET_NAME = "TargetName";
public static final String TYPE = "Type";
/** Contains type for statements such as MyClass.class */
public static final String TYPE_REF = "TypeRef";

public static final String USAGES = "Usages";
public static final String VALUE = "Value";
public static final String VIRTUAL = "Virtual";
public static final String QUERY = "Query";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class CaseSafePropertyUtil {
Schema.NAME,
Schema.RETURN_TYPE,
Schema.SUPER_CLASS_NAME,
Schema.SUPER_INTERFACE_NAME);
Schema.SUPER_INTERFACE_NAME,
Schema.TARGET_NAME);

static void addCaseSafeProperty(
GraphTraversal<Vertex, Vertex> traversal, String property, Object value) {
Expand Down
Loading