Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

SV.STRUTS.PRIVATE

This error appears when a Class extends an org.apache.struts.action.ActionForm and has a class field that is not private.

Vulnerability and risk

ActionForm class should contain only private fields which are accessed by setter and getter. Creating non-private fields violated this contract and has introduced the possibility of avoiding validation and creating an invalid state for the Form object.

Klocwork security vulnerability (SV) checkers identify calls that create potentially dangerous data; these calls are considered unsafe sources. An unsafe source can be any data provided by the user, since the user could be an attacker or has the potential for introducing human error.

Mitigation and prevention

Make all fields private. Use getter to get the value of the field. Setter should be used only by the framework; setting an action form field from other actions is bad practice and should be avoided.

Example 1

10 public class SV_STRUTS_PRIVATE_Sample_1 extends ActionForm {
11     private String name;
12     protected String birthdayString;
13     public String getName() {
14         return name;
15     }
16     public void setName(String name) {
17         this.name = name;
18     }
19     public String getBirthday() {
20         return birthdayString;
21     }
22     public void setBirthday(String birthday) {
23         this.birthdayString = birthday;
24     }
25 }

SV.STRUTS.PRIVATE is reported for field declaration on line 12: Struts: Form field 'birthdayString' should be private