Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML generator #2767

Closed
ruban-thilak opened this issue May 27, 2023 · 1 comment
Closed

HTML generator #2767

ruban-thilak opened this issue May 27, 2023 · 1 comment

Comments

@ruban-thilak
Copy link
Contributor

ruban-thilak commented May 27, 2023

Is your feature request related to a problem? Please describe it.

The problem is related to testing HTML sanitization in a Rails application. Currently, there is a need for a new HTML generator that can generate HTML code with various elements and attributes to test the effectiveness of the HTML sanitization process. This will help identify any potential vulnerabilities or issues in the sanitization implementation.

If you're adding new objects, please describe how you would use them.

The proposed HTML generator can be used in test suites to generate HTML code with different elements and attributes. This will allow developers to test the effectiveness of the HTML sanitization process in the Rails application. Here's an example of how the generator could be used in a test case:

# Example test case using the HTML generator
require 'rails_helper'

RSpec.describe 'HTML sanitization' do
  it 'sanitizes user-generated HTML' do
    input_html = Faker::HTML.random # Generate HTML code using the new generator
    sanitized_html = sanitize_html(input_html) # Call the HTML sanitization method

    # Assert that the sanitized HTML does not contain any potentially harmful elements or attributes
    expect(sanitized_html).not_to include('<script>')
    expect(sanitized_html).not_to include('onclick')
  end
end

This way, the new HTML generator will allow developers to simulate different scenarios and ensure that the HTML sanitization process is working as expected.

Describe alternatives you've considered

One alternative would be manually creating HTML test cases with different elements and attributes. However, this approach can be time-consuming and error-prone, especially when dealing with a large number of test cases. Having a dedicated HTML generator would automate the process and make it easier to generate a wide variety of test cases.

@thdaraujo
Copy link
Contributor

closed by #2769

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants