{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":28772,"path":"it-operations-management/agent-client-collector/configure-license-key-rule.md","title":"Configure a license key discovery rule and write a parser script","bundle":null,"doc_type":null,"release":"australia","body":"\n# Configure a license key discovery rule and write a parser script\n\nEnable license key discovery to verify the legitimacy of your software installation. Set up support for a new vendor's license file format by creating a parser script and defining a matching rule.\n\n## Before you begin\n\nRole required: agent\\_client\\_collector\\_admin or discovery\\_admin\n\n## About this task\n\nTo discover license keys from a vendor's license file format, you must create the following complementary configuration records:\n\n-   A parser script that knows how to extract license information from the specified file format.\n-   A file-matching rule that tells the framework when to invoke that parser.\n\nThe parser is created first because the file-matching rule references it.\n\n## Procedure\n\n1.  Write the parser script on the **License Parsers** page.\n\n    1.  Enter **sn\\_acc\\_vis\\_content\\_license\\_parser.list** into the navigation menu.\n\n    2.  Select **New**.\n\n    3.  Enter a name into the **Parser Name** field.\n\n    The parser is a small piece of server-side JavaScript that receives the raw text content of a matched file and extracts license information from it.\n\n    The script must extract the following information where available:\n\n    -   Product name\n    -   Vendor name\n    -   License key\n    -   Expiry date \\(if present in the file\\)\n    The script must set a variable called `answer` to an array of result objects. Create one object per license entry found in the file — a single file can contain multiple products' licenses. If the script fails to set `answer` as an array, the parser is treated as invalid.\n\n    Example structure of a result object:\n\n    ```\n    {\n      product_name: \"Product Name\",\n      vendor: \"Vendor Name\",\n      license_key: \"ABC123DEF456\",\n      expiry_date: \"2026-12-31\"\n    }\n    ```\n\n2.  Validate the parser script before using it on real data.\n\n    Every License Parser record includes a **Test Parser** link in the **Related Links** section. To validate your script, do the following on the License Parser record page:\n\n    1.  Fill in the **sample\\_input** field with representative file content.\n    2.  Fill in the **sample\\_output** field with the exact result you expect the parser to produce.\n    3.  Select **Test Parser**.\n    The Test Parser executes your script against the sample input using the exact same code path used during a real scan. It reports whether the actual result matches the expected sample output, catching mistakes before the parser processes real license files.\n\n3.  Create a License File Configuration record to define the matching rule.\n\n    With the validated parser in place, create a License File Configuration record that describes which file to look for. Enter **sn\\_acc\\_vis\\_content\\_license\\_file\\_config.list** in the navigation menu and specify the following:\n\n    -   **display\\_name** — A unique name identifying the rule\n    -   **file\\_name** — The file name or partial name to match \\(for example, \"ProductLicense\"\\)\n    -   **file\\_name\\_condition** — How to match the file name: `exact_match` \\(default\\), `starts_with`, `ends_with`, or `contains`\n    -   **file\\_extension** — Optional file extension to narrow the match further \\(do not include a leading dot before the extension\\)\n    -   **platform** — The operating system\\(s\\) the rule applies to: `all` \\(default\\), `windows`, `linux`, or `mac`\n    -   **parser** — Reference to the parser created in the previous steps\n    -   **order** — Priority when multiple rules could match the same file \\(default 100; lower values win\\)\n    -   **active** — Indicates whether the rule is currently in use \\(default = true\\)\n4.  Enable license key discovery in the system.\n\n    Ensure that the following components are active:\n\n    -   System property `sn_acc_vis_content.enable_license_key_discovery` — Set to **true**\n    -   Policy `File Based Discovery Policy - License Key` — **Active**\n    -   Check definition `File Based Discovery - License Key` — **Active**\n    After enabling these components, the agent will begin scanning for files matching your License File Configuration rule during its regular file-scanning activity.\n\n\n## Result\n\nYour new rule is active and the agent will automatically discover license keys from files matching your configuration. The discovered licenses appear in the appropriate tables when they are successfully matched in the software catalog.\n\n**Parent Topic:**[License key discovery](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/agent-client-collector/license-key-discovery.md)\n\n"}}