Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lightning-flow-scanner-core

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightning-flow-scanner-core - npm Package Compare versions

Comparing version 2.33.0 to 3.0.0

tests/multibug.test.ts

6

out/index.js

@@ -18,9 +18,5 @@ "use strict";

function scan(flows, ruleOptions) {
const ruleMap = new Map();
let scanResults;
if ((ruleOptions === null || ruleOptions === void 0 ? void 0 : ruleOptions.rules) && Object.entries(ruleOptions.rules).length > 0) {
for (const [ruleName, rule] of Object.entries(ruleOptions.rules)) {
ruleMap.set(ruleName, rule);
}
scanResults = (0, ScanFlows_1.ScanFlows)(flows, ruleMap);
scanResults = (0, ScanFlows_1.ScanFlows)(flows, ruleOptions);
}

@@ -27,0 +23,0 @@ else {

import * as core from '../../main/internals/internals';
export declare function ScanFlows(flows: core.Flow[], rulesConfig?: Map<string, {}>): core.ScanResult[];
export declare function ScanFlows(flows: core.Flow[], ruleOptions?: core.IRulesConfig): core.ScanResult[];

@@ -28,9 +28,12 @@ "use strict";

const GetRuleDefinitions_1 = require("./GetRuleDefinitions");
const Keys_1 = require("./Keys");
const core = __importStar(require("../../main/internals/internals"));
function ScanFlows(flows, rulesConfig) {
function ScanFlows(flows, ruleOptions) {
const flowResults = [];
let selectedRules = [];
if (rulesConfig) {
selectedRules = (0, GetRuleDefinitions_1.GetRuleDefinitions)(rulesConfig);
if (ruleOptions && ruleOptions.rules) {
const ruleMap = new Map();
for (const [ruleName, rule] of Object.entries(ruleOptions.rules)) {
ruleMap.set(ruleName, rule);
}
selectedRules = (0, GetRuleDefinitions_1.GetRuleDefinitions)(ruleMap);
}

@@ -47,9 +50,6 @@ else {

let config = undefined;
if (rulesConfig) {
const configKeys = (0, Keys_1.keys)(rulesConfig);
let matchedKey = configKeys.find(element => element = rule.name);
config = rulesConfig.get(matchedKey);
config['severity'];
if (ruleOptions && ruleOptions['rules'] && ruleOptions['rules'][rule.name]) {
config = ruleOptions['rules'][rule.name];
}
const result = config && Object.keys(config).length > 0 ? rule.execute(flow, config) : rule.execute(flow);
const result = (config && Object.keys(config).length > 0) ? rule.execute(flow, config) : rule.execute(flow);
if (result.severity !== rule.severity) {

@@ -56,0 +56,0 @@ result.severity = rule.severity;

{
"name": "lightning-flow-scanner-core",
"version": "2.33.0",
"version": "3.0.0",
"main": "out/**",

@@ -5,0 +5,0 @@ "types": "index.d.ts",

@@ -22,9 +22,5 @@ import {IRuleDefinition} from './main/interfaces/IRuleDefinition';

const ruleMap = new Map<string, {}>();
let scanResults: ScanResult[];
if (ruleOptions?.rules && Object.entries(ruleOptions.rules).length > 0) {
for (const [ruleName, rule] of Object.entries(ruleOptions.rules)) {
ruleMap.set(ruleName, rule);
}
scanResults = ScanFlows(flows, ruleMap);
scanResults = ScanFlows(flows, ruleOptions);
} else {

@@ -31,0 +27,0 @@ scanResults = ScanFlows(flows);

import { GetRuleDefinitions } from './GetRuleDefinitions';
import { keys } from './Keys';
import * as core from '../../main/internals/internals';
export function ScanFlows(flows: core.Flow[], rulesConfig?: Map<string, {}>): core.ScanResult[] {
export function ScanFlows(flows: core.Flow[], ruleOptions?: core.IRulesConfig): core.ScanResult[] {
const flowResults: core.ScanResult[] = [];
let selectedRules: core.IRuleDefinition[] = [];
if (rulesConfig) {
selectedRules = GetRuleDefinitions(rulesConfig);
if (ruleOptions && ruleOptions.rules) {
const ruleMap = new Map<string, {}>();
for (const [ruleName, rule] of Object.entries(ruleOptions.rules)) {
ruleMap.set(ruleName, rule);
}
selectedRules = GetRuleDefinitions(ruleMap);
} else {

@@ -17,3 +21,3 @@ selectedRules = GetRuleDefinitions();

try{
try {
const ruleResults: core.RuleResult[] = [];

@@ -24,9 +28,7 @@ for (const rule of selectedRules) {

let config = undefined;
if (rulesConfig) {
const configKeys = keys(rulesConfig);
let matchedKey = configKeys.find(element => element = rule.name);
config = rulesConfig.get(matchedKey);
config['severity'];
if (ruleOptions && ruleOptions['rules'] && ruleOptions['rules'][rule.name]) {
config = ruleOptions['rules'][rule.name];
}
const result = config && Object.keys(config).length > 0 ? rule.execute(flow, config) : rule.execute(flow);
const result = (config && Object.keys(config).length > 0) ? rule.execute(flow, config) : rule.execute(flow);
if (result.severity !== rule.severity) {

@@ -36,3 +38,3 @@ result.severity = rule.severity;

ruleResults.push(result);
} catch (error) {
} catch (error) {
throw new error("Something went wrong while executing " + rule.name + " in the Flow: '" + flow.name + "'");

@@ -46,3 +48,3 @@ }

}
catch (error) {
catch (error) {
console.log(error.message)

@@ -49,0 +51,0 @@ }

import { assert, expect } from 'chai';
import 'mocha';
import * as core from '../src'
import * as core from '../src/index'
import Hidenav from './testfiles/api58test.json';

@@ -5,0 +5,0 @@

import { assert, expect } from 'chai';
import 'mocha';
import * as core from '../src'
import Hidenav from './testfiles/hidenav.json';
import unconnectedElement from './testfiles/UnconnectedElement.json';

@@ -11,4 +11,4 @@ describe('A flow with correct naming', () => {

flow = new core.Flow({
path: './testfiles/CreateANewAccount.flow-meta.xml',
xmldata: Hidenav,
path: './testfiles/Async_OnlyTransaction.flow-meta.xml',
xmldata: unconnectedElement,
});

@@ -24,3 +24,3 @@ });

severity: 'error',
expression: '[A-Za-z0-9]'
expression: '[A-Za-z0-9]+_[A-Za-z0-9]+'
},

@@ -27,0 +27,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc