node-yara-rs

git clone git://archive.git.mtrnord.blog/MTRNord/node-yara-rs.git
Log | Files | Refs | README | LICENSE

index.d.ts (3218B)


      1 /* tslint:disable */
      2 /* eslint-disable */
      3 
      4 /* auto-generated by NAPI-RS */
      5 
      6 export interface YaraRule {
      7   filename?: string
      8   string?: string
      9   namespace?: string
     10 }
     11 export interface YaraVariable {
     12   id: string
     13   value: number | number | boolean | string
     14 }
     15 export interface YaraRuleResult {
     16   /** Name of the rule. */
     17   identifier: string
     18   /** Namespace of the rule. */
     19   namespace: string
     20   /** Metadatas of the rule. */
     21   metadatas: Array<YaraRuleMetadata>
     22   /** Tags of the rule. */
     23   tags: Array<string>
     24   /** Matcher strings of the rule. */
     25   strings: Array<YaraString>
     26 }
     27 export interface YaraRuleMetadata {
     28   identifier: string
     29   value: number | string | boolean
     30 }
     31 export interface YaraString {
     32   /** Name of the string, with the '$'. */
     33   identifier: string
     34   /** Matches of the string for the scan. */
     35   matches: Array<YaraMatch>
     36 }
     37 export interface YaraMatch {
     38   base: number
     39   /** Offset of the match within the scanning area. */
     40   offset: number
     41   /** Length of the file. Can be useful if the matcher string has not a fixed length. */
     42   length: number
     43   /** Matched data. */
     44   data: Array<number>
     45   /** If utf-8 then we decode it here */
     46   stringData?: string
     47 }
     48 /**
     49  * An interface to use yara with node in a stable manner using Rust
     50  * @public
     51  */
     52 export class YaraCompiler {
     53   /**
     54    * Constructs a new Yara instance and compiles the provided rules and variables.
     55    *
     56    * @param rules - The rules which shall be compiled.
     57    * @param variables - The variables you want to pass to the rules.
     58    * @throws This can throw if there is an unexpected error.
     59    *
     60    * @returns A new instance of a YaraScanner which can be used to scan data
     61    */
     62   constructor(rules: Array<YaraRule>, variables: Array<YaraVariable>)
     63   /**
     64    * Creates a new yara scanner for the rules defined earlier.
     65    * This can be called multiple times
     66    *
     67    * @returns A {@link YaraScanner} instance
     68    */
     69   newScanner(): YaraScanner
     70 }
     71 /**
     72  * An interface to use yara with node in a stable manner using Rust
     73  * @public
     74  */
     75 export class YaraScanner {
     76   /**
     77    * Scan a buffer of data with yara
     78    *
     79    * @param buffer - The data which shall be scanned by yara.
     80    * @throws This can throw if there is an unexpected error.
     81    *
     82    * @returns The results of yara scan_mem.
     83    */
     84   scanBuffer(buffer: Buffer): Array<YaraRuleResult>
     85   /**
     86    * Scan a string of data with yara
     87    *
     88    * @param input - The data which shall be scanned by yara.
     89    * @throws This can throw if there is an unexpected error.
     90    *
     91    * @returns The results of yara scan_mem.
     92    */
     93   scanString(input: string): Array<YaraRuleResult>
     94   /**
     95    * Scan a file with yara
     96    *
     97    * @param filepath - The path to the file yara shall scan
     98    * @throws This can throw if there is an unexpected error.
     99    *
    100    * @returns The results of yara scan_mem.
    101    */
    102   scanFile(filepath: string): Array<YaraRuleResult>
    103   /**
    104    * Scan a process with yara
    105    *
    106    * @param pid - The process id of the process that shall be scanned.
    107    * @throws This can throw if there is an unexpected error.
    108    *
    109    * @returns The results of yara scan_mem.
    110    */
    111   scanProcess(pid: number): Array<YaraRuleResult>
    112   defineVariable(identifier: string, value: string | number | number | boolean): void
    113 }