Esempio n. 1
0
        private void ParseRuleFromDescription()
        {
            var rule = new ReportingDescriptor
            {
                Id = _reader.GetAttribute(_strings.ClassIdAttribute)
            };

            _reader.Read();
            while (!AtEndOf(_strings.Description))
            {
                if (AtStartOfNonEmpty(_strings.Abstract))
                {
                    string content = _reader.ReadElementContentAsString();
                    rule.ShortDescription = new MultiformatMessageString {
                        Text = FortifyUtilities.ParseFormattedContentText(content)
                    };
                }
                else if (AtStartOfNonEmpty(_strings.Explanation))
                {
                    string content = _reader.ReadElementContentAsString();
                    rule.FullDescription = new MultiformatMessageString {
                        Text = FortifyUtilities.ParseFormattedContentText(content)
                    };
                }
                else if (AtStartOfNonEmpty(_strings.CustomDescription))
                {
                    // Skip the custom description block
                    while (!AtEndOf(_strings.CustomDescription))
                    {
                        _reader.Read();
                    }
                }
                else
                {
                    _reader.Read();
                }
            }

            _ruleIdToIndexMap[rule.Id] = _ruleIdToIndexMap.Count;
            _rules.Add(rule);
        }
Esempio n. 2
0
        private void ParseRuleDescriptions()
        {
            string ruleId            = _reader.GetAttribute(_strings.ClassIdAttribute);
            ReportingDescriptor rule = FindOrCreateRule(ruleId, out int ruleIndex);

            _reader.Read();
            while (!AtEndOf(_strings.Description))
            {
                if (AtStartOfNonEmpty(_strings.Abstract))
                {
                    string content = _reader.ReadElementContentAsString();
                    rule.ShortDescription = new MultiformatMessageString {
                        Text = FortifyUtilities.ParseFormattedContentText(content)
                    };
                }
                else if (AtStartOfNonEmpty(_strings.Explanation))
                {
                    string content = _reader.ReadElementContentAsString();
                    rule.FullDescription = new MultiformatMessageString {
                        Text = FortifyUtilities.ParseFormattedContentText(content)
                    };
                }
                else if (AtStartOfNonEmpty(_strings.CustomDescription))
                {
                    // Skip the custom description block.
                    while (!AtEndOf(_strings.CustomDescription))
                    {
                        _reader.Read();
                    }
                }
                else
                {
                    _reader.Read();
                }
            }
        }