예제 #1
0
def _build_ruleset(template_linters):
    """
    Combines the RuleSets from the provided template_linters into a single, aggregate RuleSet.

    Arguments:
        template_linters: A list of linting objects.

    Returns:
        The combined RuleSet.
    """
    return reduce(lambda combined, current: combined + current.ruleset,
                  template_linters, RuleSet())
예제 #2
0
"""
Custom AST NodeVisitor classes uses for Python xss linting.
"""
from __future__ import absolute_import

import ast
import re

from xsslint.reporting import ExpressionRuleViolation
from xsslint.rules import RuleSet
from xsslint.utils import Expression, ParseString, StringLines

ruleset = RuleSet(
    python_concat_html='python-concat-html',
    python_deprecated_display_name='python-deprecated-display-name',
    python_requires_html_or_text='python-requires-html-or-text',
    python_close_before_format='python-close-before-format',
    python_wrap_html='python-wrap-html',
    python_interpolate_html='python-interpolate-html',
)


class BaseVisitor(ast.NodeVisitor):
    """
    Base class for AST NodeVisitor used for Python xss linting.

    Important: This base visitor skips all __repr__ function definitions.
    """
    def __init__(self, file_contents, results):
        """
        Init method.