@lcap/nasl-parser
Version:
Take Nasl text to Nasl AST with the help of generalized parsing.
29 lines (24 loc) • 957 B
text/typescript
import * as nasl from './toAST/decorated-nasl-ast';
import { Visitor } from './toAST/common-util';
export function extractFirstLogic(arg : nasl.App) {
return arg.logics[0];
}
export function removeSomeProperties(ast : any, props: string[]) {
return new Visitor().preOrderVisitAll(null, ast, (env, obj) => {
if (!obj) {
return obj;
}
for (const prop of props) {
if (obj[prop] !== undefined) {
delete obj[prop];
}
}
return obj;
}, null);
}
export const removeUnimportantProps = (arg : any) => {
return removeSomeProperties(arg,
['changedTime', 'uuid', 'offsetX', 'offsetY', 'folded', 'playground', '_aiUID', 'ideVersion', 'configuration']
.concat(['inferred', 'handleError', 'hideMembers', 'keyword', 'composedBy', 'cron', 'overridable', 'transactional', 'triggerType', 'applyAnnotations']));
}
// , 'description', 'name', 'label'