Skip to content

Commit 1abc1de

Browse files
committed
White list sortexpression for sql injection
# Conflicts: # Build/CommonAssemblyInfo.cs
1 parent 558ab2f commit 1abc1de

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("3.3.1")]
19-
[assembly: AssemblyFileVersion("3.3.1")]
18+
[assembly: AssemblyVersion("3.3.2")]
19+
[assembly: AssemblyFileVersion("3.3.2")]
2020
//[assembly: AssemblyInformationalVersion("2.5-filters")]

Griddly.Mvc/GriddlyResult.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,18 @@ public override void ExecuteResult(ControllerContext context)
6868
}
6969

7070
var griddlyContext = context.Controller.GetOrCreateGriddlyContext();
71-
GriddlySettings settings = null;
71+
GriddlySettings settings = GriddlySettingsResult.GetSettings(context, ViewName);
7272

73-
if (context.IsChildAction)
73+
if (griddlyContext.SortFields?.Length > 0)
7474
{
75-
settings = GriddlySettingsResult.GetSettings(context, ViewName);
75+
// white list for sql injection
76+
griddlyContext.SortFields = griddlyContext.SortFields
77+
.Where(x => settings.Columns.Any(y => y.ExpressionString == x.Field))
78+
.ToArray();
79+
}
7680

81+
if (context.IsChildAction)
82+
{
7783
GriddlySettings.OnGriddlyResultExecuting?.Invoke(settings, context);
7884

7985
// TODO: should we always pull sort fields?
@@ -101,7 +107,6 @@ public override void ExecuteResult(ControllerContext context)
101107
Total = GetCount(),
102108
PageSize = griddlyContext.PageSize,
103109
SortFields = griddlyContext.SortFields,
104-
Settings = settings,
105110
PopulateSummaryValues = PopulateSummaryValues
106111
};
107112

@@ -127,8 +132,6 @@ public override void ExecuteResult(ControllerContext context)
127132
}
128133
else
129134
{
130-
settings = GriddlySettingsResult.GetSettings(context, ViewName);
131-
132135
settings.Columns.RemoveAll(x => x is GriddlySelectColumn);
133136

134137
ActionResult result;

Griddly.Mvc/GriddlyResultPage.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public class GriddlyResultPage
1616

1717
public int PageSize { get; set; }
1818

19-
public GriddlySettings Settings { get; set; }
20-
2119
public Action<GriddlySettings> PopulateSummaryValues { get; set; }
2220
}
2321

0 commit comments

Comments
 (0)