Beispiel #1
0
 public void XssWindow(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "window\\.",
         ReportTerms.IssueDescriptions.XssWindow
         );
 }
Beispiel #2
0
 public void ServerSideScript(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "<script runat=\"?server\"?",
         ReportTerms.IssueDescriptions.ServerSideScript
         );
 }
Beispiel #3
0
 public void XssRequest(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "[ (.]request\\.",
         ReportTerms.IssueDescriptions.XssRequest
         );
 }
Beispiel #4
0
 public void XssDocument(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "<script .*?document\\.",
         ReportTerms.IssueDescriptions.XssDocument
         );
 }
Beispiel #5
0
 public void XssHttpContext(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "[ (.]httpcontext\\.",
         ReportTerms.IssueDescriptions.XssHttpContext
         );
 }
Beispiel #6
0
 public void XssServer(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "[ (.]server\\.",
         ReportTerms.IssueDescriptions.XssServer
         );
 }
Beispiel #7
0
 public void XssQueryString(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "[ (.]querystring",
         ReportTerms.IssueDescriptions.XssQueryString
         );
 }
Beispiel #8
0
 public void XssQueryHelper(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "queryhelper\\.",
         ReportTerms.IssueDescriptions.XssQueryHelper
         );
 }
Beispiel #9
0
 public void QueryMacro(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "{\\?.*|{%.*querystring",
         ReportTerms.IssueDescriptions.QueryMacro
         );
 }
Beispiel #10
0
 public void DocumentsMacro(CmsTransformation transformation)
 {
     UseRegexAnalysis(
         transformation,
         "{%.*?documents[[.]",
         ReportTerms.IssueDescriptions.DocumentsMacro
         );
 }
Beispiel #11
0
        private void AnalyzeTransformation(CmsTransformation transformation)
        {
            var issueAnalyzersObject = new IssueAnalyzers(Metadata.Terms);

            var issueAnalyzerPublicInstanceMethods = issueAnalyzersObject
                                                     .GetType()
                                                     .GetMethods(BindingFlags.Public | BindingFlags.Instance)
                                                     .Where(method => method.ReturnType == typeof(void));

            foreach (var issueAnalyzerPublicInstanceMethod in issueAnalyzerPublicInstanceMethods)
            {
                issueAnalyzerPublicInstanceMethod.Invoke(
                    issueAnalyzersObject,
                    new object[]
                {
                    transformation
                }
                    );
            }
        }
Beispiel #12
0
        private static void UseRegexAnalysis(
            CmsTransformation transformation,
            string pattern,
            Term issueDescription,
            [CallerMemberName] string?issueType = null
            )
        {
            var regex = new Regex(
                pattern,
                RegexOptions.IgnoreCase | RegexOptions.CultureInvariant
                );

            var regexMatches = regex.Matches(transformation.TransformationCode);

            if (regexMatches.Count == 0)
            {
                return;
            }

            if (!string.IsNullOrEmpty(issueType))
            {
                DetectedIssueTypes.TryAdd(
                    issueType,
                    issueDescription
                    );

                foreach (Match?match in regex.Matches(transformation.TransformationCode))
                {
                    if (match != null)
                    {
                        transformation.AddIssue(
                            match.Index,
                            match.Length,
                            issueType
                            );
                    }
                }
            }
        }