User tried to perform a Keyword Scan using keywordGroup and patternGroup within one KeywordScan section.
Received the error
INFO perl: out: [KeywordScan] ERROR XML: file:/F://CAST//Tools//CASTHLAutomation-main//Config//KeywordScanFiles//KeywordScanTest.xml:0: Schemas validity error : Element 'patternGroup': This element is not expected. Expected is ( keywordGroup ).
Below is the keywordScan XML file used which created the issue
<?xml version="1.0" encoding="utf-8"?>
<UserScan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="KeywordModel.xsd">
<keywordScan name="Search" version="1.0" >
<keywordGroup name="TFTP_Search" weight="1" sensitive="0" full_word="0">
<keywordItem id="1">[\\.]TFTPClient</keywordItem>
<keywordItem id="2">[\\.]ChannelSTftp</keywordItem>
<keywordItem id="3">[\\.]TFTPSClient</keywordItem>
</keywordGroup>
<patternGroup name="Dependencies" weight="1" sensitive="0" full_word="0">
<patterns>
<search id="Maven">
<filename>pom.xml</filename>
<regexContent>dependencies[\\>]</regexContent>
</search>
</patterns>
</patternGroup>
</keywordScan>
</UserScan>
If the patternGroup is removed from the keywordScan tag it works fine.
Details
The patternGroup and keywordGroup can't exist in the single same keywordScan section. Each keywordScan section should be either:
- patternGroup
or:
-keywordGroup
but not both.
This is as per the xsd schema file
A corrected keywordScan XML file would be
<?xml version="1.0" encoding="utf-8"?>
<UserScan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="KeywordModel.xsd">
<keywordScan name="Search" version="1.0" >
<keywordGroup name="TFTP_Search" weight="1" sensitive="0" full_word="0">
<keywordItem id="1">[\\.]TFTPClient</keywordItem>
<keywordItem id="2">[\\.]ChannelSTftp</keywordItem>
<keywordItem id="3">[\\.]TFTPSClient</keywordItem>
</keywordGroup>
</keywordScan>
<keywordScan name="Search" version="1.0" >
<patternGroup name="Dependencies" weight="1" sensitive="0" full_word="0">
<patterns>
<search id="Maven">
<filename>pom.xml</filename>
<regexContent>dependencies[\\>]</regexContent>
</search>
</patterns>
</patternGroup>
</keywordScan>
</UserScan>
Please refer
How to configure a Keyword Scan for GDPR (or anything else)
Ticket
48118,
NB:
What is a keyword group?
keywordGroup mode is essentially meant to count occurrences of simple keywords to feed a score and density of a set of keywords. This mode will be preferred when you need to observe and measure frequent use of keywords.
What is a pattern group?
patternGroup mode is meant to verify the presence of a keyword or a combination of keywords, eventually within specific contexts (e.g. in specific file extensions, specific file names, etc.). This mode uses regular expressions and will be preferred when you need to observe and detect rare use of keywords
Related Articles
Getting Started Guide for Keyword Scan (PDF)
Sample Configuration Files (ZIP)
Tutorial to Detect use of Oracle’s JDK 1.8 in applications
Comments