Skip to content

When REPORT_PERCENTAGE is set to 100%, the report-uri directive is not always included in the CSP header #231

@robhudson

Description

@robhudson

When the setting REPORT_PERCENTAGE is set to 100%, the report-uri should always be included in the Content Security Policy header. However, it has been observed that this is not true.

The current logic allows this issue to occur because when the randomly generated integer equals 100, the condition to include the report-uri is not met. Specifically, the check 100 < 100 evaluates to False, which results in the report-uri being omitted from the CSP header. This effectively means that even with REPORT_PERCENTAGE set to 100%, there is a scenario where the report-uri is not included, preventing the expected reporting of CSP violations.

        include_report_uri = random.randint(0, 100) < report_percentage
        if not include_report_uri:
            replace["report-uri"] = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions