Skip to content

Commit d523aa1

Browse files
committed
Committing the event simulator file configuration csrf fix
1 parent 9e289ab commit d523aa1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

components/event-simulator/org.wso2.carbon.event.simulator.ui/src/main/resources/web/eventsimulator/index.jsp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
2323
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
24+
<%@ taglib uri="http://www.owasp.org/index.php/Category:OWASP_CSRFGuard_Project/Owasp.CsrfGuard.tld" prefix="csrf" %>
2425

2526
<script type="text/javascript" src="../ajax/js/prototype.js"></script>
2627
<script type="text/javascript" src="../admin/js/breadcrumbs.js"></script>
@@ -199,7 +200,7 @@
199200

200201

201202
<div id="fileArea">
202-
<form name="csvFileForm" id="csvFileForm" method="post" action="../../fileupload/csv" enctype="multipart/form-data"
203+
<form name="csvFileForm" id="csvFileForm" method="post" action="../../fileupload/csv?<csrf:tokenname/>=<csrf:tokenvalue/>" enctype="multipart/form-data"
203204
target="_self">
204205

205206
<table class="styledLeft">

components/event-simulator/org.wso2.carbon.event.simulator.ui/src/main/resources/web/eventsimulator/js/stream_configuration.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,23 @@ function sendConfiguration(form){
113113
var jsonString="{\"FileName\":\""+fileName+"\",\"streamID\":\""+streamName+"\",\"seperateChar\":\""+seperateChar+"\"" +
114114
",\"delayBetweenEventsInMilies\":"+delayBetweenEventsInMilies+"}";
115115

116+
var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest : new window.ActiveXObject("Microsoft.XMLHTTP");
117+
xhr.open("POST", "/carbon/admin/js/csrfPrevention.js", false);
118+
xhr.setRequestHeader("FETCH-CSRF-TOKEN", "1");
119+
xhr.send(null);
120+
121+
var token_pair = xhr.responseText;
122+
token_pair = token_pair.split(":");
123+
var token_name = token_pair[0];
124+
var token_value = token_pair[1];
125+
116126
jQuery.ajax({
117127
type: "POST",
118128
url: "../eventsimulator/sendConfigValues_ajaxprocessor.jsp?jsonData=" + jsonString + "",
129+
beforeSend: function(xhr){xhr.setRequestHeader(token_name, token_value);},
130+
data: {},
131+
contentType: "application/json; charset=utf-8",
132+
dataType: "text",
119133
async: false,
120134

121135
success:function(msg){

0 commit comments

Comments
 (0)