All files / src/rules unsecure_fae.ts

100% Statements 63/63
100% Branches 16/16
100% Functions 6/6
100% Lines 63/63

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 631x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10326x 10326x 10326x 10326x 10326x 30801x 30801x 30801x 30801x 30801x 30801x 30801x 30801x 10326x 10326x 9812x 9812x 10326x 10326x 244x 244x 244x 10326x 10326x 241x 241x 10326x 10326x 310x 310x 62x 62x 248x 248x 310x 27x 27x 221x 310x 228x 228x 1x 1x 1x 1x 228x 221x 221x 221x 10326x 10326x
import * as Expressions from "../abap/2_statements/expressions";
import {Issue} from "../issue";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRegistry} from "../_iregistry";
import {IRule, IRuleMetadata, RuleTag} from "./_irule";
import {IObject} from "../objects/_iobject";
import {ABAPObject} from "../objects/_abap_object";
import {SyntaxLogic} from "../abap/5_syntax/syntax";
 
export class UnsecureFAEConf extends BasicRuleConfig {
}
 
export class UnsecureFAE implements IRule {
  private reg: IRegistry;
  private conf = new UnsecureFAEConf();
 
  public getMetadata(): IRuleMetadata {
    return {
      key: "unsecure_fae",
      title: "Unsecure FAE",
      shortDescription: `Checks for unsecure FAE`,
      extendedInformation: `Issues from rule check_syntax must be fixed before this rule takes effect`,
      tags: [RuleTag.Experimental, RuleTag.Performance],
    };
  }
 
  public getConfig() {
    return this.conf;
  }
 
  public initialize(reg: IRegistry) {
    this.reg = reg;
    return this;
  }
 
  public setConfig(conf: UnsecureFAEConf) {
    this.conf = conf;
  }
 
  public run(obj: IObject): Issue[] {
    const issues: Issue[] = [];
    if (!(obj instanceof ABAPObject)) {
      return issues;
    }
 
    const syntaxResult = new SyntaxLogic(this.reg, obj).run();
    if (syntaxResult.issues.length > 0) {
      return issues;
    }
 
    for (const f of obj.getABAPFiles()) {
      // todo
      for (const e of f.getStructure()?.findAllExpressions(Expressions.SQLForAllEntries) || []) {
        const token = e.getFirstToken();
        const message = "Unsecure FAE";
        issues.push(Issue.atToken(f, token, message, this.getMetadata().key, this.getConfig().severity));
      }
    }
 
    return issues;
  }
 
}