0

私たちの Web サイトでクロスサイト スクリプティング (XSS) を防止するタスクが与えられました。この概念は私にとって新しいものであり、私はたくさんグーグルで検索し、owasp-java-html-sanitizer を入手しました。で独自のポリシーを作成しました

public static final PolicyFactory POLICY_DEFINITION = new HtmlPolicyBuilder()

を使用し.allowAttributesてデザインしました。しかし今、私はそれを使用する方法がわかりません...次のコードスニペットを見つけました:

System.err.println("[Reading from STDIN]");
    // Fetch the HTML to sanitize.
    String html = CharStreams.toString(new InputStreamReader(System.in,
            Charsets.UTF_8));
    // Set up an output channel to receive the sanitized HTML.
    HtmlStreamRenderer renderer = HtmlStreamRenderer.create(System.out,
    // Receives notifications on a failure to write to the output.
            new Handler<IOException>() {
                public void handle(IOException ex) {
                    Throwables.propagate(ex); // System.out suppresses
                                                // IOExceptions
                }
            },
            // Our HTML parser is very lenient, but this receives
            // notifications on
            // truly bizarre inputs.
            new Handler<String>() {
                public void handle(String x) {
                    throw new AssertionError(x);
                }
            });
    // Use the policy defined above to sanitize the HTML.
    HtmlSanitizer.sanitize(html, POLICY_DEFINITION.apply(renderer));
}

しかし、これは単純な HTML 用だと思うので、どうすればこれを JSP に適用できますか。助けてください。

4

1 に答える 1