Writing rules in Fortify

99封情书 提交于 2020-01-15 19:23:43

问题


Does anybody know how to write a rule in HP Fortify SCA to check for an XML tag value in an XLM file?

I have an XML like this with a regular expression and want to write a rule which checks whether the element matches a regex.

<xml>
 <email>[a-z]@.com]</email>
</xml>

回答1:


This is done with an XML style ConfigurationRule. I'm not sure if you want to match the value against a regular expression, or determine that the value is itself a regular expression. But regardless I will provide the structure of the rule and you are on your own for the pattern.

<?xml version="1.0" encoding="UTF-8"?>
    <RulePack xmlns="xmlns://www.fortifysoftware.com/schema/rules"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RulePack">
        <RulePackID>D1B37203-B532-4F4F-BF1F-BA8796CABF21</RulePackID>
        <SKU>SKU-D1B37203-B532-4F4F-BF1F-BA8796CABF21</SKU>
        <Name><![CDATA[ rulepack name ]]></Name>
        <Version>1.0</Version>
        <Description><![CDATA[Description for .xml]]></Description>
        <Rules version="3.11">
            <RuleDefinitions>
                <ConfigurationRule formatVersion="3.11">
                    <RuleID>1C80C1A2-10DF-40C3-B1B7-FCC3D7BD42F7</RuleID>
                    <VulnKingdom>Code Quality</VulnKingdom>
                    <VulnCategory>Email in XYZ Configuration</VulnCategory>
                    <DefaultSeverity>5.0</DefaultSeverity>
                    <Description formatVersion="3.2"></Description>
                    <ConfigFile type="xml">
                        <Pattern>test.*\.xml</Pattern>
                    </ConfigFile>
                    <XPathMatch expression="/xml/email[text()='abc@foo']" reporton="/xml/email" />
                </ConfigurationRule>
            </RuleDefinitions>
        </Rules>
    </RulePack>


来源:https://stackoverflow.com/questions/7634663/writing-rules-in-fortify

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!