This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Struts"
Jeffcityjon (talk | contribs) |
Jeffcityjon (talk | contribs) (→Validation) |
||
Line 22: | Line 22: | ||
<li>The Validator plug-in should be enabled in struts-config.xml | <li>The Validator plug-in should be enabled in struts-config.xml | ||
<p><pre> | <p><pre> | ||
− | + | <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> | |
− | + | <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validator.xml"/> | |
− | + | </plug-in> | |
</pre></p></li> | </pre></p></li> | ||
</ul> | </ul> |
Revision as of 20:16, 23 January 2008
Status
Content to be finalized. First draft
Overview
Struts is an Apache framework aimed at simplifying the creation of dynamic web applications in Java.
Struts is built on a MVC architecture, which means the application is arranged into 3 primary types of code. These are know as a Model, View and Controller. The Model defines the structure of your data being processed. The View defines everything that a end user can see. The controller take the model as submitted from the page, performs business logic on the data, then decides what view should be responsible for displaying the result.
I will not spend any more time talking about the architecture of struts. If you would like to have more information on that topic, I suggest going to the official website.
Security in the Model
Validation
The Struts Validation Framework is the primary method of validating a struts based application. Struts validation consists of a few elements to be setup. To properly use Struts validation your application should have the following...
- A validator-rules.xml file in the WEB-INF folder.
- A validator.xml in the WEB-INF folder.
- All ActionForms should extend org.apache.struts.validator.ValidatorForm or org.apache.struts.validator.ValidatorActionForm instead of org.apache.struts.action.ActionForm.
- The commons-validator.jar in WEB-INF. This can be obtained here.
- The Validator plug-in should be enabled in struts-config.xml
<plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validator.xml"/> </plug-in>
Examples
Struts Validation in an ActionForm
Struts Validation in validator.xml using an ActionForm
Struts Validation in validator.xml using a DynaValidatorForm
Security in the View
Output Sanitation
TODO: More data here.
Security in the Controller
Roles
In the struts-config.xml configuration file it is possible to specify a roles attribute, a comma-delimited list of security role names that are allowed access to the ActionMapping object. This is pretty much all that you get out of the box.
<action roles="administrator,contributor" path="/article/Edit" parameter="org.article.FindByArticle" name="articleForm" scope="request"> <forward name="success" path="article.jsp"/> </action>
Custom Action Mappings
It is possible to implement far more complex security models if you extend the action mappings.
TODO: Lots more detail here.
Error Handling
TODO: Put some info here
Common errors and vulnerabilities
Form Does Not Extend Validation Class