progpilot API

January 9, 2023 · View on GitHub

$obj_context is an instance of class \progpilot\Context

Inputs


  • objcontext>inputs>setFolder(obj_context->inputs->setFolder(folder);
  • objcontext>inputs>setFile(obj_context->inputs->setFile(file);
    where file is the path to file which exists on the disk, example ./myfile.php
  • objcontext>inputs>setCode(obj_context->inputs->setCode(code);
    where code is the contents/code of a file, for example *code=filegetcontents("./myfile.php");ifbothoptionsaresetwhentheanalyzeislaunchedthepriorityisgiventoanalyzethecode = file_get_contents("./myfile.php");* if both options are set when the analyze is launched the priority is given to analyze the file.
    if all options are set when the analyze is launched the priority is given to analyze the folder.Toretrievethevalueoffolder. To retrieve the value of file, codeandcode and folder use these methods:
  • $obj_context->inputs->getFile();
  • $obj_context->inputs->getCode();
  • $obj_context->inputs->getFolder();


  • objcontext>inputs>setDev(obj_context->inputs->setDev(bool);
    If you want to use security data relative to development of progpilot (default is false)


  • objcontext>inputs>addSources(obj_context->inputs->addSources(files_sources);
  • objcontext>inputs>setSources(obj_context->inputs->setSources(files_sources);
  • objcontext>inputs>addSinks(obj_context->inputs->addSinks(files_sinks);
  • objcontext>inputs>setSinks(obj_context->inputs->setSinks(files_sinks);
  • objcontext>inputs>addSanitizers(obj_context->inputs->addSanitizers(files_sanitizers);
  • objcontext>inputs>setSanitizers(obj_context->inputs->setSanitizers(files_sanitizers);
  • objcontext>inputs>addValidators(obj_context->inputs->addValidators(files_validators);
  • objcontext>inputs>setValidators(obj_context->inputs->setValidators(files_validators);
  • objcontext>inputs>addCustomRules(obj_context->inputs->addCustomRules(files_custom);
  • objcontext>inputs>setCustomRules(obj_context->inputs->setCustomRules(files_custom);
  • $obj_context->inputs->getCustomRules();
  • $obj_context->inputs->getSources();
  • $obj_context->inputs->getSinks();
  • $obj_context->inputs->getSanitizers();
  • $obj_context->inputs->getValidators();
    These methods are mainly explained in the chapter specify an analyze and customize an analyze
    If a file (sources, sinks, sanitizers, validators, custom rules) is not specified the default file will be used.


  • objcontext>inputs>setResolvedIncludes(obj_context->inputs->setResolvedIncludes(mixed);
    This function is explained in the chapter about included files
  • objcontext>inputs>setFalsePositives(obj_context->inputs->setFalsePositives(mixed);
    These functions are explained in the chapter about handling false positives


  • objcontext>inputs>setInclusions(obj_context->inputs->setInclusions(mixed);
  • objcontext>inputs>setExclusions(obj_context->inputs->setExclusions(mixed);
    For include or exclude files and folders during the analysis, see an example here with a json file configuration and an example here with a php array.

Outputs


  • objcontext>outputs>setWriteIncludeFailures(obj_context->outputs->setWriteIncludeFailures(bool);
  • objcontext>outputs>setIncludeFailuresFile(obj_context->outputs->setIncludeFailuresFile(file);
    These functions are explained in the chapter about included files
  • $obj_context->outputs->getAst();
  • $obj_context->outputs->getCfg();
  • $obj_context->outputs->getCallGraph();
  • objcontext>outputs>taintedFlow(obj_context->outputs->taintedFlow(bool);
    true or false if you want to print the complete flow of assignments that taints a variable used by a sink function (default is false: only the last tainted variable is printed).
  • objcontext>outputs>setOnAddResult(obj_context->outputs->setOnAddResult(func);
    for each vulnerability found by progpilot the function func will be called with the vulnerability as argument.
  • $obj_context->outputs->getCountAnalyzedFiles();
    print the number of files analyzed (it does not count the included files (with include() for example in PHP)).

Options


  • objcontext>setMaxDefinitions(obj_context->setMaxDefinitions(nb);
    to prevent memory exhaustion you could limit the number of definitions by file during the analysis (default is 3000)
  • objcontext>setMaxFileAnalysisDuration(obj_context->setMaxFileAnalysisDuration(time_sec);
    max execution time by file for some steps of the analysis (default is 10 seconds)
  • objcontext>setMaxFileSize(obj_context->setMaxFileSize(size_bytes);
    do not analyze file that are larger than this defined size (default is 500 000 bytes)
  • objcontext>setDebugMode(obj_context->setDebugMode(bool);
    true if you want to output warnings during the analysis, default is false
  • objcontext>setPrettyPrint(obj_context->setPrettyPrint(bool);
    true if you want to pretty print the JSON output of standalone progpilot application, default is true
  • objcontext>setAnalyzeIncludes(obj_context->setAnalyzeIncludes(bool);
    true or false if you want to analyze included files, default is true
  • objcontext>setConfiguration(obj_context->setConfiguration(config);
    you can use an yaml file to specify the configuration of analysis, see an example here. These rules are explained in the chapter customize an analyze