Update the checkers.xml file

Now it's time to add your KAST expression to the <pattern> tags in the checkers.xml file. This file should also contain an accurate title and message for your custom checker.

  1. Open the checkers.xml file in an editor of your choice. For our example, this file is located in C.KAST.CUST.FUNC/checkers.xml.

When the file was generated, its values were automatically populated with an error ID, severity, message, and title, as well as a sample KAST expression. For more information about the tags in this file, see checkers.xml: Checker configuration.

  1. Look for the <pattern> tag.
  2. Replace the sample KAST expression with the KAST expression:
    ExprStmt / Expr::BinaryExpr [ @Op = KTC_OPCODE_ASR ] [ getMostleftArg().isCin() ] [ Right.isPointer() | Right.isArray() ]
    
  3. You can also edit the <error> node's attributes, as required. For this tutorial, we'll change the title attribute to read "C_KAST_Custom_Function" and the message attribute to read "dangerous input stream usage".
  4. Save the file.