|
12 | 12 |
|
13 | 13 | using System;
|
14 | 14 | using System.Collections.Generic;
|
| 15 | +using System.Data.Odbc; |
15 | 16 | using System.Linq;
|
16 | 17 | using System.Management.Automation.Language;
|
17 | 18 | using Microsoft.Windows.Powershell.ScriptAnalyzer.Generic;
|
@@ -46,28 +47,24 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
|
46 | 47 | {
|
47 | 48 | //Check if XPath is used. If XPath is used, then we don't throw warnings.
|
48 | 49 | Ast parentAst = expressionAst.Parent;
|
49 |
| - IEnumerable<Ast> invocation = parentAst.FindAll(test => test is InvokeMemberExpressionAst, true); |
50 |
| - bool hasXPath = false; |
51 |
| - if (invocation != null) |
| 50 | + if (parentAst is InvokeMemberExpressionAst) |
52 | 51 | {
|
53 |
| - foreach (InvokeMemberExpressionAst ieAst in invocation) |
| 52 | + InvokeMemberExpressionAst invocation = parentAst as InvokeMemberExpressionAst; |
| 53 | + if (invocation != null) |
54 | 54 | {
|
55 |
| - if (String.Equals(ieAst.Member.ToString(), "SelectSingleNode",StringComparison.OrdinalIgnoreCase) || |
56 |
| - String.Equals(ieAst.Member.ToString(), "SelectNodes",StringComparison.OrdinalIgnoreCase) || |
57 |
| - String.Equals(ieAst.Member.ToString(), "Select",StringComparison.OrdinalIgnoreCase) || |
58 |
| - String.Equals(ieAst.Member.ToString(), "Evaluate",StringComparison.OrdinalIgnoreCase) || |
59 |
| - String.Equals(ieAst.Member.ToString(), "Matches",StringComparison.OrdinalIgnoreCase)) |
| 55 | + if (String.Equals(invocation.Member.ToString(), "SelectSingleNode",StringComparison.OrdinalIgnoreCase) || |
| 56 | + String.Equals(invocation.Member.ToString(), "SelectNodes",StringComparison.OrdinalIgnoreCase) || |
| 57 | + String.Equals(invocation.Member.ToString(), "Select", StringComparison.OrdinalIgnoreCase) || |
| 58 | + String.Equals(invocation.Member.ToString(), "Evaluate",StringComparison.OrdinalIgnoreCase) || |
| 59 | + String.Equals(invocation.Member.ToString(), "Matches",StringComparison.OrdinalIgnoreCase)) |
60 | 60 | {
|
61 |
| - hasXPath = true; |
62 |
| - break; |
| 61 | + continue; |
63 | 62 | }
|
| 63 | + |
64 | 64 | }
|
65 | 65 | }
|
66 |
| - if (hasXPath) |
67 |
| - { |
68 |
| - continue; |
69 |
| - } |
70 |
| - |
| 66 | + |
| 67 | + |
71 | 68 | bool isPathValid = false;
|
72 | 69 | bool isInternalURL = false;
|
73 | 70 | //make sure there is no path
|
|
0 commit comments