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.
- 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.
- Look for the <pattern> tag.
- Replace the sample KAST expression with the KAST expression:
ExprStmt / Expr::BinaryExpr [ @Op = KTC_OPCODE_ASR ] [ getMostleftArg().isCin() ] [ Right.isPointer() | Right.isArray() ]
- 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".
- Save the file.