Socket
Socket
Sign inDemoInstall

@appland/scanner

Package Overview
Dependencies
326
Maintainers
4
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.78.0 to 1.79.0

built/lastGitOrFSModifiedDate.js

14

built/cli/upload.js

@@ -18,16 +18,4 @@ "use strict";

const vars_1 = require("../integration/vars");
const promises_2 = require("fs/promises");
const path_1 = require("path");
const pruneAppMap_1 = require("./upload/pruneAppMap");
function fileExists(file) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, promises_2.stat)(file);
return true;
}
catch (e) {
return false;
}
});
}
function create(scanResults, appId, appMapDir, mergeKey, mapsetOptions = {}, retryOptions = {}) {

@@ -51,3 +39,3 @@ return __awaiter(this, void 0, void 0, function* () {

const filePaths = [filePath, (0, path_1.join)(appMapDir, filePath)];
const filePathsExist = yield Promise.all(filePaths.map(fileExists));
const filePathsExist = yield Promise.all(filePaths.map(util_1.fileExists));
const fullPath = filePaths.find((_, fileIndex) => filePathsExist[fileIndex]);

@@ -54,0 +42,0 @@ if (!fullPath)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const octokit_1 = require("octokit");
const vars_1 = require("../vars");

@@ -10,5 +11,7 @@ function postCommitStatus(state, description) {

// eslint-disable-next-line @typescript-eslint/no-var-requires
const octokat = require('octokat');
const octo = new octokat({ token: (0, vars_1.token)() });
return octo.repos((0, vars_1.owner)(), (0, vars_1.repo)()).statuses((0, vars_1.sha)()).create({
const octo = new octokit_1.Octokit({ auth: (0, vars_1.token)() });
return octo.rest.repos.createCommitStatus({
owner: (0, vars_1.owner)(),
repo: (0, vars_1.repo)(),
sha: (0, vars_1.sha)(),
state: state,

@@ -15,0 +18,0 @@ context: 'appland/scanner',

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("@appland/models");
const errors_1 = require("./errors");

@@ -27,2 +28,14 @@ const util_1 = require("./rules/lib/util");

const hashV2_1 = __importDefault(require("./algorithms/hash/hashV2"));
const path_1 = require("path");
const lastGitOrFSModifiedDate_1 = __importDefault(require("./lastGitOrFSModifiedDate"));
const console_1 = require("console");
const assert_1 = __importDefault(require("assert"));
function locationToFilePath(location) {
const [file] = location.split(':');
let filePath = file;
if ((0, path_1.isAbsolute)(file) && file.startsWith(process.cwd())) {
filePath = file.slice(process.cwd().length + 1);
}
return filePath;
}
class RuleChecker {

@@ -98,6 +111,40 @@ constructor(progress) {

}
let appmapConfigDir;
{
let searchDir = (0, path_1.dirname)((0, path_1.resolve)(appMapFileName));
while (!appmapConfigDir) {
if (yield (0, util_1.fileExists)((0, path_1.join)(searchDir, 'appmap.yml'))) {
appmapConfigDir = searchDir;
}
else {
if ((0, path_1.dirname)(searchDir) === searchDir)
break;
searchDir = (0, path_1.dirname)(searchDir);
}
}
}
const resolvePath = (path) => __awaiter(this, void 0, void 0, function* () {
const candidates = [path];
if (appmapConfigDir)
candidates.push((0, path_1.join)(appmapConfigDir, path));
for (const candidate of candidates)
if (yield (0, util_1.fileExists)(candidate))
return candidate;
});
const mostRecentModifiedDate = (filePaths) => __awaiter(this, void 0, void 0, function* () {
const dates = new Array();
for (const filePath of filePaths) {
const resolvedPath = yield resolvePath(filePath);
if (!resolvedPath)
continue;
const date = yield (0, lastGitOrFSModifiedDate_1.default)(resolvedPath);
if (date)
dates.push(date);
}
return dates.sort((a, b) => (a && b ? b.getTime() - a.getTime() : 0))[0];
});
const buildFinding = (matchEvent, participatingEvents, message, groupMessage, occurranceCount,
// matchEvent will be added to additionalEvents and participatingEvents.values
// to create the relatedEvents array
additionalEvents) => {
additionalEvents) => __awaiter(this, void 0, void 0, function* () {
const findingEvent = matchEvent || event;

@@ -118,14 +165,52 @@ // Fixes:

additionalEvents || []);
let scopeModifiedDate;
{
const scopeNavigator = new models_1.EventNavigator(scope);
const scopeFiles = new Set();
const collectScope = (event) => {
if (!event.codeObject.location)
return;
const filePath = locationToFilePath(event.codeObject.location);
if (!filePath)
return;
scopeFiles.add(filePath);
};
collectScope(scope);
for (const descendant of scopeNavigator.descendants()) {
const { event } = descendant;
collectScope(event);
}
const localScopeFiles = [...scopeFiles].filter((filePath) => ((0, assert_1.default)(filePath), !(0, path_1.isAbsolute)(filePath)));
scopeModifiedDate = yield mostRecentModifiedDate(localScopeFiles);
}
const hashV2 = new hashV2_1.default(checkInstance.ruleId, findingEvent, participatingEvents);
const uniqueEvents = new Set();
const relatedEvents = [];
[findingEvent, ...(additionalEvents || []), ...Object.values(participatingEvents)]
.map(eventUtil_1.cloneEvent)
.forEach((event) => {
const relatedEventFiles = new Set();
const collectEventFile = (event) => {
if (!event.codeObject.location)
return;
const filePath = locationToFilePath(event.codeObject.location);
if (!filePath)
return;
if ((0, path_1.isAbsolute)(filePath))
return;
relatedEventFiles.add(filePath);
};
[findingEvent, ...(additionalEvents || []), ...Object.values(participatingEvents)].forEach((event) => {
if (uniqueEvents.has(event.id)) {
return;
}
collectEventFile(event);
for (const ancestor of new models_1.EventNavigator(event).ancestors()) {
collectEventFile(ancestor.event);
}
uniqueEvents.add(event.id);
relatedEvents.push((0, eventUtil_1.cloneEvent)(event));
});
const eventsModifiedDate = yield mostRecentModifiedDate([...relatedEventFiles]);
if ((0, util_1.verbose)()) {
(0, console_1.warn)(`Scope modified date: ${scopeModifiedDate}`);
(0, console_1.warn)(`Events modified date: ${eventsModifiedDate}`);
}
return {

@@ -147,4 +232,6 @@ appMapFile: appMapFileName,

participatingEvents: Object.fromEntries(Object.entries(participatingEvents).map(([k, v]) => [k, (0, eventUtil_1.cloneEvent)(v)])),
scopeModifiedDate,
eventsModifiedDate,
};
};
});
if (this.progress)

@@ -160,6 +247,6 @@ yield this.progress.matchEvent(event, appMapIndex);

const message = checkInstance.ruleLogic.message(scope, event);
finding = buildFinding(event, {}, message);
finding = yield buildFinding(event, {}, message);
}
else {
finding = buildFinding(event, {});
finding = yield buildFinding(event, {});
}

@@ -169,3 +256,3 @@ findings.push(finding);

else if (typeof matchResult === 'string') {
const finding = buildFinding(event, {}, matchResult);
const finding = yield buildFinding(event, {}, matchResult);
finding.message = matchResult;

@@ -175,6 +262,6 @@ findings.push(finding);

else if (matchResult) {
matchResult.forEach((mr) => {
const finding = buildFinding(mr.event, mr.participatingEvents || {}, mr.message, mr.groupMessage, mr.occurranceCount, mr.relatedEvents);
for (const mr of matchResult) {
const finding = yield buildFinding(mr.event, mr.participatingEvents || {}, mr.message, mr.groupMessage, mr.occurranceCount, mr.relatedEvents);
findings.push(finding);
});
}
}

@@ -181,0 +268,0 @@ if ((0, util_1.verbose)()) {

@@ -15,3 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.verbose = exports.toRegExpArray = exports.responseContentType = exports.toRegExp = exports.providesAuthentication = exports.pluralize = exports.dasherize = exports.camelize = exports.parseValue = exports.isRoot = exports.ideLink = exports.isTruthy = exports.isFalsey = exports.emptyValue = exports.capitalize = exports.appMapDir = exports.collectAppMapFiles = void 0;
exports.verbose = exports.toRegExpArray = exports.responseContentType = exports.toRegExp = exports.providesAuthentication = exports.pluralize = exports.dasherize = exports.camelize = exports.parseValue = exports.isRoot = exports.ideLink = exports.isTruthy = exports.isFalsey = exports.fileExists = exports.emptyValue = exports.capitalize = exports.appMapDir = exports.collectAppMapFiles = void 0;
const path_1 = require("path");

@@ -21,2 +21,3 @@ const util_1 = require("util");

const assert_1 = __importDefault(require("assert"));
const promises_1 = require("fs/promises");
function collectAppMapFiles(appmapFile, appmapDir) {

@@ -169,1 +170,13 @@ return __awaiter(this, void 0, void 0, function* () {

exports.pluralize = pluralize;
function fileExists(file) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield (0, promises_1.stat)(file);
return true;
}
catch (e) {
return false;
}
});
}
exports.fileExists = fileExists;
{
"name": "@appland/scanner",
"version": "1.78.0",
"version": "1.79.0",
"description": "Analyze AppMaps for code flaws",

@@ -22,3 +22,5 @@ "bin": "built/cli.js",

"ci": "yarn lint && yarn build && yarn schema-up-to-date && yarn doc-up-to-date && yarn test",
"test": "jest --filter=./test/testFilter.js",
"test": "appmap-agent-js && jest -t @appmap-fixme --filter=./test/testFilter.js",
"test:no-appmap": "yarn jest",
"jest": "jest --filter=./test/testFilter.js",
"semantic-release": "semantic-release",

@@ -30,2 +32,3 @@ "watch": "node bin/preBuild.js && tsc -p tsconfig.build.json --watch"

"devDependencies": {
"@appland/appmap-agent-js": "^13.9.0",
"@semantic-release/changelog": "^6.0.1",

@@ -77,3 +80,3 @@ "@semantic-release/git": "^10.0.1",

"cli-progress": "^3.11.0",
"conf": "^10.0.2",
"conf": "10.2.0",
"crypto-js": "^4.0.0",

@@ -85,3 +88,3 @@ "glob": "7.2.3",

"minimatch": "^5.1.2",
"octokat": "^0.10.0",
"octokit": "^2.0.19",
"openapi-diff": "^0.23.5",

@@ -88,0 +91,0 @@ "ora": "~5",

@@ -119,2 +119,4 @@ import { AppMap, Event } from '@appland/models';

participatingEvents?: Record<string, Event>;
scopeModifiedDate?: Date;
eventsModifiedDate?: Date;
}

@@ -121,0 +123,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc