New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

burp-brightscript

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

burp-brightscript - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

2

CHANGELOG.md

@@ -1,2 +0,2 @@

#### 0.4.0 (2020-06-16)
#### 0.4.1 (2020-07-09)

@@ -3,0 +3,0 @@ ##### New Features

export { BurpConfig } from './lib/BurpConfig';
export { FileProcessor } from './lib/FileProcessor';
export { BurpProcessor } from './lib/BurpProcessor';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FileProcessor_1 = require("./lib/FileProcessor");
exports.FileProcessor = FileProcessor_1.FileProcessor;
var BurpProcessor_1 = require("./lib/BurpProcessor");
exports.BurpProcessor = BurpProcessor_1.BurpProcessor;
//# sourceMappingURL=index.js.map

@@ -13,4 +13,5 @@ import { BurpConfig } from './BurpConfig';

private functionNameRegex;
processFile(fileDescriptor: FileDescriptor): boolean;
processFileWithPath(absolutePath: string, isUsingGlobalReplace?: boolean): string | undefined;
processFile(fileDescriptor: FileDescriptor, isUsingGlobalReplace?: boolean, isSaving?: boolean): boolean;
getFunctionFromLine(line: string): any;
}
"use strict";
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
var Debug = require("debug");
var path = require("path");
var FileDescriptor_1 = require("./FileDescriptor");
var MacroValue_1 = require("./MacroValue");

@@ -15,5 +27,2 @@ var os = require('os');

this._errors = [];
this._config.replacements.forEach(function (replacement) {
replacement._regex = new RegExp(replacement.regex, 'i');
});
}

@@ -34,3 +43,18 @@ Object.defineProperty(FileProcessor.prototype, "errors", {

});
FileProcessor.prototype.processFile = function (fileDescriptor) {
FileProcessor.prototype.processFileWithPath = function (absolutePath, isUsingGlobalReplace) {
if (isUsingGlobalReplace === void 0) { isUsingGlobalReplace = false; }
try {
var fd = new FileDescriptor_1.default(path.dirname(path.resolve(absolutePath)), path.basename(absolutePath), path.extname(absolutePath).toLowerCase());
var success = this.processFile(fd, isUsingGlobalReplace, false);
return success ? fd.fileContents : undefined;
}
catch (e) {
console.error(e);
}
return undefined;
};
FileProcessor.prototype.processFile = function (fileDescriptor, isUsingGlobalReplace, isSaving) {
var e_1, _a, e_2, _b;
if (isUsingGlobalReplace === void 0) { isUsingGlobalReplace = false; }
if (isSaving === void 0) { isSaving = true; }
var code = fileDescriptor ? fileDescriptor.fileContents : null;

@@ -42,57 +66,91 @@ if (!code || !code.trim()) {

}
var name = fileDescriptor.normalizedFileName;
var filename = fileDescriptor.normalizedFileName;
var currentLocation = '';
var lines = code.split(/\r?\n/);
var filePath = fileDescriptor.fullPath;
var packagePath = filePath = fileDescriptor.getPackagePath('', this.rootPath);
var functionName = NO_FUNCTION;
var isInFunction = false;
var isDirty = false;
var _loop_1 = function (lineNumber) {
currentLocation = filePath + ':' + lineNumber.toString();
var line = lines[lineNumber - 1];
if (isInFunction) {
if (this_1.functionEndRegex.test(line)) {
isInFunction = false;
functionName = NO_FUNCTION;
if (isUsingGlobalReplace) {
var filename = fileDescriptor.normalizedFileName;
var currentLocation = '';
var filePath = fileDescriptor.fullPath;
var packagePath = filePath = fileDescriptor.getPackagePath('', this.rootPath);
var functionName = NO_FUNCTION;
var isInFunction = false;
var isDirty = false;
var isBrs = fileDescriptor.extension.toLowerCase() === '.brs';
var lines = code.split(/\r?\n/);
for (var lineNumber = 1; lineNumber <= lines.length; lineNumber++) {
currentLocation = filePath + ':' + lineNumber.toString();
var line = lines[lineNumber - 1];
if (isInFunction) {
if (this.functionEndRegex.test(line)) {
isInFunction = false;
functionName = NO_FUNCTION;
}
}
else {
var functionNameMatch = this.getFunctionFromLine(line);
if (functionNameMatch) {
isInFunction = true;
functionName = functionNameMatch;
}
}
try {
//run each of the user's regex's and replace with the replaced text
for (var _c = __values(this._config.replacements), _d = _c.next(); !_d.done; _d = _c.next()) {
var replacement = _d.value;
if (replacement.replacement === MacroValue_1.MacroValue.CommentLine) {
if (line.match(replacement.regex)) {
line = "'" + line;
}
isDirty = true;
}
else if (line.match(new RegExp(replacement.regex, 'ig'))) {
var replacementValue = replacement.replacement;
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FileName, filename);
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FullPath, packagePath + "(" + lineNumber.toString() + ")");
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FunctionName, functionName);
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.LineNumber, lineNumber.toString().trim());
if (isBrs) {
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.SourceLocation, "\"" + packagePath + "(" + lineNumber.toString() + ")\"");
}
line = line.replace(new RegExp(replacement.regex, 'ig'), replacementValue);
console.log(line);
isDirty = true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_1) throw e_1.error; }
}
lines[lineNumber - 1] = line;
if (isDirty) {
fileDescriptor.setFileContents(lines.join(os.EOL));
if (isSaving) {
fileDescriptor.saveFileContents();
}
}
}
else {
var functionNameMatch = this_1.getFunctionFromLine(line);
if (functionNameMatch) {
isInFunction = true;
functionName = functionNameMatch;
}
else {
var oldCode = code;
try {
for (var _e = __values(this._config.replacements), _f = _e.next(); !_f.done; _f = _e.next()) {
var replacement = _f.value;
code = code.replace(new RegExp(replacement.regex, 'gim'), replacement.replacement);
}
}
//run each of the user's regex's and replace with the replaced text
this_1._config.replacements.forEach(function (replacement) {
if (replacement.replacement === MacroValue_1.MacroValue.CommentLine) {
if (line.match(replacement.regex)) {
line = "'" + line;
}
isDirty = true;
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
}
else if (line.match(replacement._regex)) {
var replacementValue = replacement.replacement;
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FileName, filename);
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FullPath, packagePath + "(" + lineNumber.toString() + ")");
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FunctionName, functionName);
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.LineNumber, lineNumber.toString().trim());
replacementValue = replacementValue.replace(MacroValue_1.MacroValue.FullLocation, packagePath + "(" + lineNumber.toString() + ")." + functionName);
line = line.replace(replacement._regex, replacementValue);
isDirty = true;
finally { if (e_2) throw e_2.error; }
}
if (oldCode.length !== code.length) { //crude; but efficient for our purposes
fileDescriptor.setFileContents(code);
if (isSaving) {
fileDescriptor.saveFileContents();
}
//DO the regex match here
});
lines[lineNumber - 1] = line;
};
var this_1 = this;
for (var lineNumber = 1; lineNumber <= lines.length; lineNumber++) {
_loop_1(lineNumber);
}
}
if (isDirty) {
fileDescriptor.setFileContents(lines.join(os.EOL));
fileDescriptor.saveFileContents();
}
return true;

@@ -99,0 +157,0 @@ };

@@ -7,3 +7,3 @@ export declare enum MacroValue {

CommentLine = "#CommentLine#",
FullLocation = "#Location#"
SourceLocation = "source_location"
}

@@ -10,4 +10,4 @@ "use strict";

MacroValue["CommentLine"] = "#CommentLine#";
MacroValue["FullLocation"] = "#Location#";
MacroValue["SourceLocation"] = "source_location";
})(MacroValue = exports.MacroValue || (exports.MacroValue = {}));
//# sourceMappingURL=MacroValue.js.map
{
"name": "burp-brightscript",
"version": "0.4.0",
"version": "0.4.1",
"description": "lightweight processor for roku brightscript projects",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

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