#ifndef __JetLint_h__ #define __JetLint_h__ #include #include #include // jetc --lint-sql: phase 2 of docs/design-sql-bound-parameters.md. // // Lists every whose body pastes a variable into the statement text // ($[...] or #[...]) instead of passing it with . These are the // queries to migrate. A value from a row of an earlier query // ($[.column], $[session.column], $[?N], $[#]) is not reported, as the // design doc specifies, unless strict is set. namespace jetc { struct LintRef { std::string text; // the reference as written, e.g. "$[:email]" std::string kind; // cgi, global, local, session, env, keyword, row, ... }; struct LintFinding { std::string file; int line; // line of the std::vector refs; }; struct LintStats { int files = 0; // files that contain at least one int sqlBlocks = 0; int flaggedBlocks = 0; }; // Scans one file's text. Appends to findings and stats. // wrappers: custom tag names whose uses count as (see // findSqlWrappers). void lintSqlText(const std::string &file, const std::string &text, bool strict, const std::vector &wrappers, std::vector &findings, LintStats &stats); // Adds to wrappers each custom tag defined in text () // whose definition runs the caller's content as its statement: // . void findSqlWrappers(const std::string &text, std::vector &wrappers); // Scans files and directories (recursively; every regular file, // whatever its extension). Tag definitions are collected from all of // them first, so a wrapper defined in one file is found in all. // Prints one line per finding and a summary. Returns 0 when nothing is found, 1 when something is, // 2 on an error (unreadable path). int lintSql(const std::vector &paths, bool strict, std::ostream &out, std::ostream &err); } #endif