- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: ruby-security/no-content-tag
Language: Ruby
Severity: Warning
Category: Security
CWE: 79
The rule “Avoid content_tag” is crucial in Ruby development as it helps prevent potential cross-site scripting (XSS) attacks. The content_tag
method in Ruby on Rails can inadvertently expose your application to XSS attacks when user input is directly passed into the method. This is because content_tag
does not escape HTML content by default, therefore, it can render potentially harmful scripts if the content includes any.
To ensure your Ruby code is secure and compliant, it’s highly recommended to use other methods that automatically escape content, such as safe_join
or tag
. Instead of using content_tag(:p, "Unsafe Code!")
, you would use tag.p("Unsafe Code!")
. Similarly, instead of content_tag(:div, content_tag(:p, "Hello!"), class: "strong")
, you would use tag.div(tag.p("Hello!"), class: "strong")
.
By avoiding the use of content_tag
, you can protect your application from potential security threats and keep your code safe and robust.
content_tag(:p, "Unsafe Code!")
content_tag(:div, content_tag(:p, "Hello!"), class: "strong")
|
|
For more information, please read the Code Analysis documentation
Identify code vulnerabilities directly in yourVS Code editor
Identify code vulnerabilities directly inJetBrains products