Skip to content

Commit 787493a

Browse files
committed
#2177 change position of ValidateAntiForgeryToken in svelte apps in header of a request because its future-proof because the ValidateAntiForgeryToken in asp.net core is checking also the header. currently also a CustomValidateAntiForgeryToken will check in this version the header. codeql will certainly not recognize this, but the check exists.
1 parent 915e6fb commit 787493a

File tree

29 files changed

+110
-678
lines changed

29 files changed

+110
-678
lines changed

Components/App/BExIS.App.Bootstrap/Attributes/CustomValidateAntiForgeryToken.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public void OnAuthorization(AuthorizationContext filterContext)
1818
var formToken = request.Form["__RequestVerificationToken"];
1919

2020
// check header for post from javascript
21+
2122
if (formToken==null)
2223
{
2324
formToken = request.Headers["__RequestVerificationToken"];

Console/BExIS.Web.Shell.Svelte/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Console/BExIS.Web.Shell.Svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
},
5353
"type": "module",
5454
"dependencies": {
55-
"@bexis2/bexis2-core-ui": "0.4.53",
55+
"@bexis2/bexis2-core-ui": "0.4.58",
5656
"@sveltejs/adapter-static": "3.0.2",
5757
"buffer": "6.0.3",
5858
"gray-matter": "4.0.3",

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
},
5151
"type": "module",
5252
"dependencies": {
53-
"@bexis2/bexis2-core-ui": "0.4.53",
53+
"@bexis2/bexis2-core-ui": "0.4.58",
5454
"@bexis2/bexis2-rpm-ui": "0.2.11",
5555
"@floating-ui/dom": "1.6.8",
5656
"@fortawesome/free-solid-svg-icons": "6.6.0",

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/CreateController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public JsonResult Get(long id)
244244

245245
[JsonNetFilter]
246246
[HttpPost]
247-
[ValidateAntiForgeryToken]
247+
[CustomValidateAntiForgeryToken]
248248
public JsonResult Create(CreateModel data)
249249
{
250250
if (data == null) return Json(false);

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EntityTemplatesController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public JsonResult Delete(long id)
7777

7878
[JsonNetFilter]
7979
[HttpPost]
80-
[ValidateAntiForgeryToken]
80+
[CustomValidateAntiForgeryToken]
8181
public JsonResult Update(EntityTemplateModel entityTemplate)
8282
{
8383
using (var entityTemplateManager = new EntityTemplateManager())

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/FormController.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,11 @@ public JsonResult UpdateSimpleUsageWithParty(string xpath, long partyId,long ent
15551555
{
15561556
try
15571557
{
1558+
if (!XmlUtility.IsSafeXPath(xpath))
1559+
{
1560+
return Json(false, JsonRequestBehavior.AllowGet);
1561+
}
1562+
15581563
AddXmlAttribute(xpath, "partyid", partyId.ToString(), entityId);
15591564

15601565
return Json(true, JsonRequestBehavior.AllowGet);
@@ -2059,13 +2064,11 @@ private StepInfo LoadStepsBasedOnUsage(BaseUsage usage, StepInfo current, string
20592064
if (usage is MetadataPackageUsage)
20602065
{
20612066
keyValueDic.Add("type", BExIS.Xml.Helpers.XmlNodeType.MetadataPackageUsage.ToString());
2062-
//elements = XmlUtility.GetXElementsByAttribute(usage.Label, keyValueDic, xMetadata).ToList();
20632067
parentXElement = XmlUtility.GetXElementByXPath(parent.XPath, xMetadata);
20642068
}
20652069
else
20662070
{
20672071
keyValueDic.Add("type", BExIS.Xml.Helpers.XmlNodeType.MetadataAttributeUsage.ToString());
2068-
//elements = XmlUtility.GetXElementsByAttribute(usage.Label, keyValueDic, xMetadata, parentXpath).ToList();
20692072
parentXElement = XmlUtility.GetXElementByXPath(parent.XPath, xMetadata);
20702073
}
20712074

@@ -2764,7 +2767,7 @@ private string storeGeneratedFilePathToContentDiscriptor(long datasetId, Dataset
27642767
/// Is called when the user write a letter in Autocomplete User Component
27652768
/// </summary>
27662769
[HttpPost]
2767-
[ValidateAntiForgeryToken]
2770+
[CustomValidateAntiForgeryToken]
27682771
public ActionResult _AutoCompleteAjaxLoading(string text, long id, string type)
27692772
{
27702773
// if mapping with etities exits
@@ -3101,6 +3104,11 @@ private void UpdateAttribute(BaseUsage parentUsage, int packageNumber, BaseUsage
31013104
//ToDo really said function, but cant find a other solution for now
31023105
private void AddXmlAttribute(string xpath, string attrName, string attrValue,long entityId)
31033106
{
3107+
if(XmlUtility.IsSafeXPath(xpath) == false)
3108+
{
3109+
throw new Exception("The provided xpath is not safe.");
3110+
}
3111+
31043112
TaskManager = FormHelper.GetTaskManager(entityId);
31053113
XDocument metadataXml = getMetadata(TaskManager);
31063114

@@ -3239,7 +3247,7 @@ private void validationAgainstJsonSchema()
32393247

32403248
//XX number of index des values nötig
32413249
[HttpPost]
3242-
[ValidateAntiForgeryToken]
3250+
[CustomValidateAntiForgeryToken]
32433251
public ActionResult ValidateMetadataAttributeUsage(string value, int id, int parentid, string parentname, int number, int parentModelNumber, int parentStepId, long entityId)
32443252
{
32453253
//delete all white spaces from start and end
@@ -3329,7 +3337,7 @@ public ActionResult ValidateMetadataAttributeUsage(string value, int id, int par
33293337
}
33303338

33313339
[HttpPost]
3332-
[ValidateAntiForgeryToken]
3340+
[CustomValidateAntiForgeryToken]
33333341
public ActionResult ValidateMetadataParameterUsage(string value, int id, long attrUsageId, int number, int parentModelNumber, int parentStepId, long entityId)
33343342
{
33353343
//delete all white spaces from start and end

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Hooks/AttachmentUploadController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public JsonResult Load(long id, int version)
8989
}
9090

9191
[HttpPost]
92-
[ValidateAntiForgeryToken]
92+
[CustomValidateAntiForgeryToken]
9393
public JsonResult Upload(long id)
9494
{
9595
// load edit dataset cache
@@ -161,7 +161,7 @@ public JsonResult Upload(long id)
161161
}
162162

163163
[HttpPost]
164-
[ValidateAntiForgeryToken]
164+
[CustomValidateAntiForgeryToken]
165165
public JsonResult RemoveFile(long id, BExIS.UI.Hooks.Caches.FileInfo file)
166166
{
167167
// load edit dataset cache
@@ -226,7 +226,7 @@ public JsonResult RemoveFile(long id, BExIS.UI.Hooks.Caches.FileInfo file)
226226
}
227227

228228
[HttpPost]
229-
[ValidateAntiForgeryToken]
229+
[CustomValidateAntiForgeryToken]
230230
public JsonResult SaveFileDescription(long id, BExIS.UI.Hooks.Caches.FileInfo file, string description)
231231
{
232232
HookManager hookManager = new HookManager();

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Hooks/DataController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public JsonResult Load(long id, int version)
106106
}
107107

108108
[HttpPost]
109-
[ValidateAntiForgeryToken]
109+
[CustomValidateAntiForgeryToken]
110110
public JsonResult RemoveFile(long id, FileInfo file)
111111
{
112112
// remove file from server
@@ -142,7 +142,7 @@ public JsonResult RemoveFile(long id, FileInfo file)
142142
/// <param name="file"></param>
143143
/// <returns></returns>
144144
[HttpPost]
145-
[ValidateAntiForgeryToken]
145+
[CustomValidateAntiForgeryToken]
146146
public JsonResult RevertFile(long id, FileInfo file)
147147
{
148148
// remove file from server
@@ -186,7 +186,7 @@ public JsonResult RevertFile(long id, FileInfo file)
186186
/// <returns></returns>
187187
/// <exception cref="Exception"></exception>
188188
[HttpPost]
189-
[ValidateAntiForgeryToken]
189+
[CustomValidateAntiForgeryToken]
190190
public JsonResult SaveFileDescription(long id, BExIS.UI.Hooks.Caches.FileInfo file)
191191
{
192192
// remove file from cache

0 commit comments

Comments
 (0)