",
36 | "type": "regex",
37 | "scopes": [ "code" ],
38 | "modifiers": [ "i" ]
39 | }
40 | ]
41 | }
42 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/os/user_accts.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "OS: User Account Write (Add)",
4 | "id": "AI038700",
5 | "description": "OS: User Account Write (Add)",
6 | "applies_to": [
7 | "csharp"
8 | ],
9 | "tags": [
10 | "OS.UserAccount.Write"
11 | ],
12 | "severity": "moderate",
13 | "patterns": [
14 | {
15 | "pattern": "NetUserAdd|NetGroupAddUser|NetLocalGroupAdd",
16 | "type": "regex-word",
17 | "scopes": [
18 | "code"
19 | ],
20 | "confidence": "high",
21 | "_comment": ""
22 | }
23 | ]
24 | },
25 | {
26 | "name": "OS: User Account Write (Modify)",
27 | "id": "AI038800",
28 | "description": "OS: User Account Write (Modify)",
29 | "applies_to": [
30 | "csharp"
31 | ],
32 | "tags": [
33 | "OS.UserAccount.Write"
34 | ],
35 | "severity": "moderate",
36 | "patterns": [
37 | {
38 | "pattern": "NetGroupSetInfo|NetGroupSetUsers|NetLocalGroupDel|NetUserChangePassword",
39 | "type": "regex-word",
40 | "scopes": [
41 | "code"
42 | ],
43 | "confidence": "high",
44 | "_comment": ""
45 | }
46 | ]
47 | }
48 | ]
--------------------------------------------------------------------------------
/RulesEngine/Resources/comments.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "language": [
4 | "c",
5 | "cpp",
6 | "csharp",
7 | "coffeescript",
8 | "fsharp",
9 | "go",
10 | "groovy",
11 | "jade",
12 | "objective-C",
13 | "rust",
14 | "swift",
15 | "javascript",
16 | "java",
17 | "typescript",
18 | "php"
19 | ],
20 | "inline": "//",
21 | "preffix": "/*",
22 | "suffix": "*/"
23 | },
24 | {
25 | "language": [
26 | "perl",
27 | "perl6",
28 | "r",
29 | "shellscript",
30 | "ruby",
31 | "yaml",
32 | "powershell",
33 | "python"
34 | ],
35 | "inline": "#",
36 | "preffix": "#",
37 | "suffix": "\n"
38 | },
39 | {
40 | "language": [
41 | "lua",
42 | "sql"
43 | ],
44 | "inline": "--",
45 | "preffix": "--",
46 | "suffix": "\n"
47 | },
48 | {
49 | "language": [
50 | "clojure"
51 | ],
52 | "inline": ";;",
53 | "preffix": ";;",
54 | "suffix": ""
55 | },
56 | {
57 | "language": [
58 | "vb"
59 | ],
60 | "inline": "'",
61 | "preffix": "'",
62 | "suffix": ""
63 | }
64 | ]
--------------------------------------------------------------------------------
/AppInspector/Writers/WriterFactory.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.AppInspector
7 | {
8 | public class WriterFactory
9 | {
10 | public static Writer GetWriter(string writerName, string defaultWritter, string format = null)
11 | {
12 | if (string.IsNullOrEmpty(writerName))
13 | writerName = defaultWritter;
14 |
15 | if (string.IsNullOrEmpty(writerName))
16 | writerName = "text";
17 |
18 | switch (writerName.ToLowerInvariant())
19 | {
20 | case "_dummy":
21 | return new DummyWriter();
22 | case "json":
23 | return new JsonWriter();
24 | case "text":
25 | return new SimpleTextWriter(format);
26 | case "html":
27 | return new LiquidWriter();
28 | default:
29 | throw new OpException(String.Format(ErrMsg.FormatString(ErrMsg.ID.CMD_INVALID_ARG_VALUE, "-f")));
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/MultiExtractor/FileEntry.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Text;
9 |
10 | namespace MultiExtractor
11 | {
12 | public class FileEntry
13 | {
14 | public FileEntry(string name, string parentPath, Stream content)
15 | {
16 | Name = name;
17 | if (string.IsNullOrEmpty(parentPath))
18 | {
19 | FullPath = Name;
20 | }
21 | else
22 | {
23 | FullPath = $"{parentPath}:{name}";
24 | }
25 | if (content == null)
26 | {
27 | throw new ArgumentNullException(nameof(content));
28 | }
29 | Content = new MemoryStream();
30 | if (content.CanSeek)
31 | {
32 | content.Position = 0;
33 | }
34 | content.CopyTo(Content);
35 | }
36 |
37 | public string FullPath { get; set; }
38 | public string Name { get; set; }
39 | public MemoryStream Content { get; set; }
40 |
41 |
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/data_handling/json_parsing.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Data: Parses JSON",
4 | "id": "AI013600",
5 | "description": "Data: Parses JSON",
6 | "applies_to": [ "javascript" ],
7 | "tags": [
8 | "Data.Parsing.JSON"
9 | ],
10 | "severity": "moderate",
11 | "patterns": [
12 | {
13 | "pattern": "JSON.Parse",
14 | "type": "string",
15 | "scopes": [
16 | "code"
17 | ]
18 | }
19 | ]
20 | },
21 | {
22 | "name": "Data: Parses JSON",
23 | "id": "AI013700",
24 | "description": "Data: Parses JSON",
25 | "applies_to": [ "csharp" ],
26 | "tags": [
27 | "Data.Parsing.JSON"
28 | ],
29 | "severity": "moderate",
30 | "patterns": [
31 | {
32 | "pattern": "JSON\\.createParser|JObject\\.Parse",
33 | "type": "regex",
34 | "scopes": [
35 | "code"
36 | ]
37 | }
38 | ]
39 | },
40 | {
41 | "name": "Data: Parses JSON",
42 | "id": "AI013800",
43 | "description": "Data: Parses JSON",
44 | "tags": [
45 | "Data.Parsing.JSON"
46 | ],
47 | "severity": "moderate",
48 | "patterns": [
49 | {
50 | "pattern": "json.*parser",
51 | "type": "regex",
52 | "scopes": [
53 | "code"
54 | ]
55 | }
56 | ]
57 | }
58 | ]
59 |
--------------------------------------------------------------------------------
/AppInspector/html/partials/_file_listing.liquid:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/general/hygiene.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Hygiene: Todo Comment",
4 | "id": "AI027300",
5 | "description": "Hygiene: Todo Comment",
6 | "tags": [
7 | "Miscellaneous.CodeHygiene.Comment.Todo"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "todo",
13 | "type": "regex",
14 | "scopes": [ "comment" ],
15 | "modifiers": [ "i" ]
16 | }
17 | ]
18 | },
19 | {
20 | "name": "Hygiene: Fix Comment",
21 | "id": "AI027400",
22 | "description": "Hygiene: Fix Comment",
23 | "tags": [
24 | "Miscellaneous.CodeHygiene.Comment.Fix"
25 | ],
26 | "severity": "moderate",
27 | "patterns": [
28 | {
29 | "pattern": "fixme|broke|broken",
30 | "type": "regex",
31 | "scopes": [ "comment" ],
32 | "modifiers": [ "i" ]
33 | }
34 | ]
35 | },
36 | {
37 | "name": "Hygiene: Suspicious Comment",
38 | "id": "AI027500",
39 | "description": "Hygiene: Suspicious Comment",
40 | "tags": [
41 | "Miscellaneous.CodeHygiene.Comment.Suspicious"
42 | ],
43 | "severity": "moderate",
44 | "patterns": [
45 | {
46 | "pattern": "hack|insecure|black magic|high risk|risky|riskiest|obfuscation|obfuscate|obfuscated",
47 | "type": "regex",
48 | "scopes": [ "comment" ],
49 | "modifiers": [ "i" ]
50 | }
51 | ]
52 | }
53 | ]
--------------------------------------------------------------------------------
/RulesEngine/PatternScope.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using System;
6 |
7 | namespace RulesEngine
8 | {
9 | [JsonConverter(typeof(PatternScopeConverter))]
10 | public enum PatternScope
11 | {
12 | All,
13 | Code,
14 | Comment,
15 | Html
16 | }
17 |
18 | ///
19 | /// Json converter for Pattern Type
20 | ///
21 | class PatternScopeConverter : JsonConverter
22 | {
23 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
24 | {
25 | PatternScope svr = (PatternScope)value;
26 | string svrstr = svr.ToString().ToLower();
27 |
28 | writer.WriteValue(svrstr);
29 | writer.WriteValue(svr.ToString().ToLower());
30 | }
31 |
32 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
33 | {
34 | var enumString = (string)reader.Value;
35 | enumString = enumString.Replace("-", "");
36 | return Enum.Parse(typeof(PatternScope), enumString, true);
37 | }
38 |
39 | public override bool CanConvert(Type objectType)
40 | {
41 | return objectType == typeof(string);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/frameworks/ruby.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Development Framework: Grails",
4 | "id": "AI025400",
5 | "description": "Development Framework: Grails",
6 | "applies_to": [ "groovy" ],
7 | "tags": [ "Framework.Development.Grails" ],
8 | "severity": "moderate",
9 | "patterns": [
10 | {
11 | "pattern": "grails",
12 | "type": "string",
13 | "scopes": [ "code" ],
14 | "modifiers": [ "i" ],
15 | "confidence": "high"
16 | }
17 | ]
18 | },
19 | {
20 | "name": "Development Framework: Rails",
21 | "id": "AI025500",
22 | "description": "Development Framework: Rails",
23 | "applies_to": [ "ruby" ],
24 | "tags": [ "Framework.Development.Rails" ],
25 | "severity": "moderate",
26 | "patterns": [
27 | {
28 | "pattern": "rails",
29 | "type": "string",
30 | "scopes": [ "code" ],
31 | "modifiers": [ "i" ],
32 | "confidence": "high"
33 | }
34 | ]
35 | },
36 | {
37 | "name": "Development Framework: Google API's",
38 | "id": "AI025600",
39 | "description": "Development Framework: Google API's",
40 | "applies_to": [ "ruby" ],
41 | "tags": [ "Framework.Development.Google.API" ],
42 | "severity": "moderate",
43 | "patterns": [
44 | {
45 | "pattern": "google/apis",
46 | "type": "sub-string",
47 | "scopes": [ "code" ],
48 | "modifiers": [ "i" ],
49 | "confidence": "high"
50 | }
51 | ]
52 | }
53 | ]
--------------------------------------------------------------------------------
/AppInspector/preferences/tagcounters.json:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 | [
4 | {
5 | "tag": "Metric.Code.Class.Defined",
6 | "displayName": "Classes",
7 | "includeAsMatch": false
8 | },
9 | {
10 | "tag": "Metric.Code.Function.Defined",
11 | "displayName": "Functions",
12 | "includeAsMatch": false
13 | },
14 | {
15 | "tag": "Metric.Code.Exception.Caught",
16 | "displayName": "Exceptions",
17 | "includeAsMatch": false
18 | },
19 | {
20 | "tag": "Metric.Code.HTMLForm.Defined",
21 | "displayName": "Forms",
22 | "includeAsMatch": true
23 | },
24 | {
25 | "tag": "Dependency.SourceInclude",
26 | "displayName": "Dependencies",
27 | "includeAsMatch": false
28 | },
29 | {
30 | "tag": "Miscellaneous.CodeHygiene.Comment.Todo",
31 | "displayName": "Comments",
32 | "includeAsMatch": false
33 | },
34 | {
35 | "tag": "Miscellaneous.CodeHygiene.Comment.Fix",
36 | "displayName": "Fix-comments",
37 | "includeAsMatch": true
38 | },
39 | {
40 | "tag": "Miscellaneous.CodeHygiene.Comment.Suspicious",
41 | "displayName": "Suspicious-comments",
42 | "includeAsMatch": true
43 | },
44 | {
45 | "tag": "Metric.Code.Logging.Call",
46 | "displayName": "Logging Calls",
47 | "includeAsMatch": false
48 | },
49 | {
50 | "tag": "Metric.Code.URL",
51 | "displayName": "URL's",
52 | "includeAsMatch": false
53 | }
54 | ]
--------------------------------------------------------------------------------
/RulesEngine/FixType.cs:
--------------------------------------------------------------------------------
1 | // Copyright(C) Microsoft.All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using System;
6 |
7 | namespace RulesEngine
8 | {
9 | ///
10 | /// Code Fix Type
11 | ///
12 | public enum FixType
13 | {
14 | RegexReplace
15 | }
16 |
17 |
18 | ///
19 | /// Json Converter for FixType
20 | ///
21 | class FixTypeConverter : JsonConverter
22 | {
23 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
24 | {
25 | FixType svr = (FixType)value;
26 | string svrstr = svr.ToString().ToLower();
27 |
28 | switch (svr)
29 | {
30 | case FixType.RegexReplace:
31 | svrstr = "regex-replace";
32 | break;
33 | }
34 | writer.WriteValue(svrstr);
35 | }
36 |
37 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
38 | {
39 | var enumString = (string)reader.Value;
40 | enumString = enumString.Replace("-", "");
41 | return Enum.Parse(typeof(FixType), enumString, true);
42 | }
43 |
44 | public override bool CanConvert(Type objectType)
45 | {
46 | return objectType == typeof(string);
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/cloud_services/ad_networks.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Miscellaneous: Advertising Network (Google Adsense)",
4 | "id": "AI000100",
5 | "description": "Miscellaneous: Advertising Network (Google Adsense)",
6 | "tags": [
7 | "CloudServices.AdvertisingNetwork.Google.Adsense"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "adsense|googleadservices\\.com",
13 | "type": "regex-word",
14 | "scopes": [ "code", "comment" ],
15 | "modifiers": []
16 | }
17 | ]
18 | },
19 | {
20 | "name": "Miscellaneous: Advertising Network (Outbrain)",
21 | "id": "AI000200",
22 | "description": "Miscellaneous: Advertising Network (Outbrain)",
23 | "tags": [
24 | "CloudServices.AdvertisingNetwork.Outbrain"
25 | ],
26 | "severity": "moderate",
27 | "patterns": [
28 | {
29 | "pattern": "outbrain.com",
30 | "type": "string",
31 | "scopes": [ "code" ],
32 | "modifiers": []
33 | }
34 | ]
35 | },
36 | {
37 | "name": "Miscellaneous: Advertising Network (Bing Ads)",
38 | "id": "AI000300",
39 | "description": "Miscellaneous: Advertising Network (Bing Ads)",
40 | "tags": [
41 | "CloudServices.AdvertisingNetwork.Microsoft.BingAds"
42 | ],
43 | "severity": "moderate",
44 | "patterns": [
45 | {
46 | "pattern": "outbrain.com",
47 | "type": "string",
48 | "scopes": [ "code" ],
49 | "modifiers": []
50 | }
51 | ]
52 | }
53 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/cloud_services/ecommerce.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "CloudServices: Financial (eCommerce)",
4 | "id": "AI003600",
5 | "description": "Data: Financial (eCommerce)",
6 | "tags": [
7 | "CloudServices.Finance.eCommerce"
8 | ],
9 | "severity": "critical",
10 | "patterns": [
11 | {
12 | "pattern": "pci|wallet|fips-140",
13 | "type": "regex-word",
14 | "scopes": [ "code" ],
15 | "modifiers": [ "i" ],
16 | "confidence": "medium"
17 | },
18 | {
19 | "pattern": "paypal|google pay|ebay|google\\.com/pay/api",
20 | "type": "regex",
21 | "scopes": [ "code", "comment" ],
22 | "modifiers": [ "i" ],
23 | "confidence": "high"
24 | },
25 | {
26 | "pattern": "price|shopping chart|payment",
27 | "type": "regex-word",
28 | "scopes": [ "code", "comment" ],
29 | "modifiers": [ "i" ]
30 | },
31 | {
32 | "pattern": "bigcommerce|shopify|bigcartel|woocommerce|wc_api_client|weebly|3dcart|squarespace|connect\\.squareup\\.com",
33 | "type": "regex",
34 | "scopes": [ "code", "comment" ],
35 | "modifiers": [ "i" ],
36 | "confidence": "high"
37 | },
38 | {
39 | "pattern": "demandware|yocart|opencart|magento|magentohost\/api|volusion|x-vtex-api-appkey|alibaba|apple.*pay",
40 | "type": "regex-word",
41 | "scopes": [ "code", "comment" ],
42 | "modifiers": [ "i" ],
43 | "confidence": "high"
44 | }
45 | ]
46 | }
47 | ]
--------------------------------------------------------------------------------
/RulesEngine/Issue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | namespace RulesEngine
5 | {
6 |
7 | ///
8 | /// Analysis Issue
9 | ///
10 | public class Issue
11 | {
12 | ///
13 | /// Creates new instance of Issue
14 | ///
15 | public Issue()
16 | {
17 | Rule = null;
18 | Boundary = new Boundary();
19 | StartLocation = new Location();
20 | IsSuppressionInfo = false;
21 | }
22 |
23 | public Confidence Confidence { get; set; }
24 |
25 | ///
26 | /// Boundary of issue (index, length)
27 | ///
28 | public Boundary Boundary { get; set; }
29 |
30 | ///
31 | /// Location (line, column) where issue starts
32 | ///
33 | public Location StartLocation { get; set; }
34 |
35 | ///
36 | /// Location (line, column) where issue ends
37 | ///
38 | public Location EndLocation { get; set; }
39 |
40 | ///
41 | /// Matching rule
42 | ///
43 | public Rule Rule { get; set; }
44 |
45 | ///
46 | /// True if Issue refers to suppression information
47 | ///
48 | public bool IsSuppressionInfo { get; set; }
49 |
50 | public SearchPattern PatternMatch { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/RulesEngine/PatternType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using System;
6 |
7 | namespace RulesEngine
8 | {
9 | ///
10 | /// Pattern Type for search pattern
11 | ///
12 | public enum PatternType
13 | {
14 | Regex,
15 | RegexWord,
16 | String,
17 | Substring
18 | }
19 |
20 | ///
21 | /// Json converter for Pattern Type
22 | ///
23 | class PatternTypeConverter : JsonConverter
24 | {
25 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
26 | {
27 | PatternType svr = (PatternType)value;
28 | string svrstr = svr.ToString().ToLower();
29 |
30 | switch (svr)
31 | {
32 | case PatternType.RegexWord:
33 | svrstr = "regex-word";
34 | break;
35 | }
36 | writer.WriteValue(svrstr);
37 | writer.WriteValue(svr.ToString().ToLower());
38 | }
39 |
40 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
41 | {
42 | var enumString = (string)reader.Value;
43 | enumString = enumString.Replace("-", "");
44 | return Enum.Parse(typeof(PatternType), enumString, true);
45 | }
46 |
47 | public override bool CanConvert(Type objectType)
48 | {
49 | return objectType == typeof(string);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/components/load_dll.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Component: Windows DLL",
4 | "id": "AI005400",
5 | "description": "Component: Windows DLL",
6 | "applies_to": [ "csharp" ],
7 | "tags": [
8 | "Component.Executable.Microsoft.DLL"
9 | ],
10 | "severity": "moderate",
11 | "patterns": [
12 | {
13 | "pattern": "DllImport|Assembly\\.LoadFile|Assembly\\.LoadFrom",
14 | "type": "regex",
15 | "modifiers": [ "i" ],
16 | "scopes": [
17 | "code"
18 | ],
19 | "confidence": "high"
20 | }
21 | ]
22 | },
23 | {
24 | "name": "Component: Windows DLL",
25 | "id": "AI005500",
26 | "description": "Component: Windows DLL",
27 | "applies_to": [ "c", "cpp" ],
28 | "tags": [
29 | "Component.Executable.Microsoft.DLL"
30 | ],
31 | "severity": "moderate",
32 | "patterns": [
33 | {
34 | "pattern": "LoadLibrary",
35 | "type": "string",
36 | "modifiers": [ "i" ],
37 | "scopes": [
38 | "code"
39 | ],
40 | "confidence": "high"
41 | }
42 | ]
43 | },
44 | {
45 | "name": "Component: Windows DLL",
46 | "id": "AI005600",
47 | "description": "Component: Windows DLL",
48 | "applies_to": [ "python", "java" ],
49 | "tags": [
50 | "Component.Executable.Microsoft.DLL"
51 | ],
52 | "severity": "moderate",
53 | "patterns": [
54 | {
55 | "pattern": "System\\.Load|ctypes\\.WinDLL",
56 | "type": "regex",
57 | "modifiers": [ "i" ],
58 | "scopes": [
59 | "code"
60 | ],
61 | "confidence": "high"
62 | }
63 | ]
64 | }
65 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/cryptography/key_derivation.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Cryptography: Key Derivation",
4 | "id": "AI009300",
5 | "description": "Cryptography: Key Derivation",
6 | "tags": [
7 | "Cryptography.KeyDerivation.General"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "KeyDerivationAlgorithmNames|SampleDeriveKeyMaterialPbkdf|RNGCryptoServiceProvider|Rfc2898DeriveBytes|KeyDerivation|DeriveKey|PasswordDeriveBytes",
13 | "type": "regex",
14 | "scopes": [ "code" ],
15 | "modifiers": [ "i" ],
16 | "confidence": "high"
17 | }
18 | ]
19 | },
20 | {
21 | "name": "Cryptography: Key Derivation (PBKDF1)",
22 | "id": "AI009400",
23 | "description": "Cryptography: Key Derivation (PBKDF1)",
24 | "tags": [
25 | "Cryptography.KeyDerivation.PBKDF1",
26 | "Cryptography.HashAlgorithm.PBKDF1"
27 | ],
28 | "severity": "moderate",
29 | "patterns": [
30 | {
31 | "pattern": "pbkdf1",
32 | "type": "regex",
33 | "scopes": [ "code" ],
34 | "modifiers": [ "i" ],
35 | "confidence": "high"
36 | }
37 | ]
38 | },
39 | {
40 | "name": "Cryptography: Key Derivation (PBKDF2)",
41 | "id": "AI009500",
42 | "description": "Cryptography: Key Derivation (PBKDF2)",
43 | "tags": [
44 | "Cryptography.KeyDerivation.PBKDF2",
45 | "Cryptography.HashAlgorithm.PBKDF1"
46 | ],
47 | "severity": "moderate",
48 | "patterns": [
49 | {
50 | "pattern": "pbkdf2",
51 | "type": "string",
52 | "scopes": [ "code" ],
53 | "modifiers": [ "i" ],
54 | "confidence": "high"
55 | }
56 | ]
57 | }
58 | ]
--------------------------------------------------------------------------------
/RulesEngine/RulesEngine.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.0
5 | RulesEngine
6 | 1.0.2
7 | Microsoft
8 | Security Static Analysis
9 | false
10 | https://github.com/Microsoft/ApplicationInspector
11 | (c) Microsoft Corporation. All rights reserved
12 | RulesEngine is used by Application Inspector exclusively as a derivitive of a non-supported .NET version of Microsoft.DevSkim as a part now of Microsoft Application Inspector.
13 |
14 | https://github.com/Microsoft/ApplicationInspector
15 | https://github.com/Microsoft/ApplicationInspector
16 | 1.0 General Release
17 | true
18 | RulesEngine
19 | RulesEngine
20 | 1.0.17
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/RulesEngine/Severity.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using System;
6 |
7 | namespace RulesEngine
8 | {
9 | ///
10 | /// Issue severity
11 | ///
12 | [Flags]
13 | public enum Severity
14 | {
15 | ///
16 | /// Critial issues
17 | ///
18 | Critical = 1,
19 | ///
20 | /// Important issues
21 | ///
22 | Important = 2,
23 | ///
24 | /// Moderate issues
25 | ///
26 | Moderate = 4,
27 | ///
28 | /// Best Practice
29 | ///
30 | BestPractice = 8,
31 | ///
32 | /// Issues that require manual review
33 | ///
34 | ManualReview = 16
35 | }
36 |
37 | ///
38 | /// Json Converter for Severity
39 | ///
40 | class SeverityConverter : JsonConverter
41 | {
42 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
43 | {
44 | Severity svr = (Severity)value;
45 | string svrstr = svr.ToString().ToLower();
46 |
47 | switch (svr)
48 | {
49 | case Severity.BestPractice:
50 | svrstr = "best-practice";
51 | break;
52 | case Severity.ManualReview:
53 | svrstr = "manual-review";
54 | break;
55 | }
56 |
57 | writer.WriteValue(svrstr);
58 | }
59 |
60 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
61 | {
62 | var enumString = (string)reader.Value;
63 | enumString = enumString.Replace("-", "");
64 | return Enum.Parse(typeof(Severity), enumString, true);
65 | }
66 |
67 | public override bool CanConvert(Type objectType)
68 | {
69 | return objectType == typeof(string);
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/AppInspector/html/resources/css/c3.min.css:
--------------------------------------------------------------------------------
1 | .c3 svg{font:10px sans-serif;-webkit-tap-highlight-color:transparent}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc rect{stroke:#fff;stroke-width:1}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:grey;font-size:2em}.c3-line{stroke-width:1px}.c3-circle{fill:currentColor}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:1;fill-opacity:.75}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-item-hidden{opacity:.15}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-title{font:14px sans-serif}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #ccc}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip .value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:#fff}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max{fill:#777}.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}.c3-chart-arc.c3-target g path{opacity:1}.c3-chart-arc.c3-target.c3-focused g path{opacity:1}.c3-drag-zoom.enabled{pointer-events:all!important;visibility:visible}.c3-drag-zoom.disabled{pointer-events:none!important;visibility:hidden}.c3-drag-zoom .extent{fill-opacity:.1}
--------------------------------------------------------------------------------
/AppInspector.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29411.108
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppInspector", "AppInspector\AppInspector.csproj", "{C6D58D43-481F-456F-90E8-FAC3779E6CC6}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{876245F3-D7C5-4AA3-A288-2CE94BF63B8E}"
9 | ProjectSection(SolutionItems) = preProject
10 | README.md = README.md
11 | EndProjectSection
12 | EndProject
13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RulesEngine", "RulesEngine\RulesEngine.csproj", "{C19A98D2-629D-4F4D-87E4-3154416970BA}"
14 | EndProject
15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiExtractor", "MultiExtractor\MultiExtractor.csproj", "{7C07A2A2-508E-4BBE-873F-F60F9FB4A9D9}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {C6D58D43-481F-456F-90E8-FAC3779E6CC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {C6D58D43-481F-456F-90E8-FAC3779E6CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {C6D58D43-481F-456F-90E8-FAC3779E6CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {C6D58D43-481F-456F-90E8-FAC3779E6CC6}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {C19A98D2-629D-4F4D-87E4-3154416970BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {C19A98D2-629D-4F4D-87E4-3154416970BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {C19A98D2-629D-4F4D-87E4-3154416970BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {C19A98D2-629D-4F4D-87E4-3154416970BA}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {7C07A2A2-508E-4BBE-873F-F60F9FB4A9D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {7C07A2A2-508E-4BBE-873F-F60F9FB4A9D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {7C07A2A2-508E-4BBE-873F-F60F9FB4A9D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {7C07A2A2-508E-4BBE-873F-F60F9FB4A9D9}.Release|Any CPU.Build.0 = Release|Any CPU
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | GlobalSection(ExtensibilityGlobals) = postSolution
40 | SolutionGuid = {1D8F88F7-47D4-475A-B1AF-713132222341}
41 | EndGlobalSection
42 | EndGlobal
43 |
--------------------------------------------------------------------------------
/AppInspector/html/resources/css/appinspector.css:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #fcfefd !important;
3 | font-family: 'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif;
4 | }
5 |
6 | a:hover {
7 | text-decoration: none;
8 | }
9 |
10 | .navbar {
11 | background-color: #F3F3F3 !important;
12 | }
13 | .navbar-brand:focus, .navbar-brand:hover {
14 | text-decoration: none !important;
15 | color: #000 !important;
16 | }
17 |
18 | .navbar-lg {
19 | min-height: 80px;
20 | border-radius: 0;
21 | padding-top: 0;
22 | padding-left: 0;
23 | padding-right: 0;
24 | padding-bottom: 5px;
25 | }
26 |
27 | .navbar-lg .navbar-brand {
28 | margin-left: 80px;
29 | font-size: 24px;
30 | font-weight: bold;
31 | color: #000;
32 | }
33 |
34 | .navbar-lg .navbar-nav > li {
35 | margin-left: 15px;
36 | margin-right: 15px;
37 | font-size: 0.90em;
38 | }
39 |
40 | .navbar-lg .navbar-nav > li > a {
41 | color: #000;
42 | }
43 |
44 | #file_listing_modal div.modal-dialog {
45 | max-width: 70%;
46 | }
47 |
48 | /* Report Overview */
49 | div.section {
50 | margin-top: 15px;
51 | margin-bottom: 15px;
52 | }
53 |
54 | #page__report_overview table tr:first-child td {
55 | border-top: 0;
56 | }
57 |
58 | #page__report_overview table td {
59 | padding: 0.10rem 0.55rem 0.10rem 0.55rem;
60 | }
61 |
62 | #page__report_overview table td:first-child {
63 | text-align: center;
64 | color: #888;
65 | }
66 |
67 | #page__report_overview table td:nth-child(2) {
68 | text-align: center;
69 | font-weight: bold;
70 | }
71 |
72 | #page__report_overview table td:nth-child(3) {
73 | color: #888;
74 | }
75 |
76 | /* Report Summary */
77 | .c3-chart-arcs-title {
78 | font-weight: bold;
79 | }
80 |
81 | /* Report Profile */
82 | #page__report_profile div.accordion {
83 | padding-bottom: 6px;
84 | border-bottom: 1px solid #0078d4;
85 | }
86 | #page__report_profile div.grid-1 {
87 | width: 32px !important;
88 | display: inline-block;
89 | text-align: center;
90 | margin-left: 6px;
91 | margin-right: 6px;
92 | color: #7FBA00;
93 | font-size: 1.4rem;
94 | }
95 |
96 | #page__report_profile div.grid-2 {
97 | font-size: 1.4rem;
98 | }
99 |
100 | #page__report_profile table td:nth-child(1) {
101 | font-weight: normal;
102 | font-size: 0.9rem;
103 | vertical-align: middle;
104 | }
105 |
106 | #page__report_profile a.disabled {
107 | color: #ccc;
108 | cursor: default;
109 | }
110 |
--------------------------------------------------------------------------------
/RulesEngine/Rule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 |
6 | namespace RulesEngine
7 | {
8 | ///
9 | /// Class to hold the Rule
10 | ///
11 | public class Rule
12 | {
13 |
14 | public Rule()
15 | {
16 | Severity = Severity.Moderate;//default
17 | }
18 | ///
19 | /// Name of the source where the rule definition came from.
20 | /// Typically file, database or other storage.
21 | ///
22 | [JsonIgnore]
23 | public string Source { get; set; }
24 |
25 | ///
26 | /// Optional tag assigned to the rule during runtime
27 | ///
28 | [JsonIgnore]
29 | public string RuntimeTag { get; set; }
30 |
31 | ///
32 | /// Runtime flag to disable the rule
33 | ///
34 | [JsonIgnore]
35 | public bool Disabled { get; set; }
36 |
37 | [JsonProperty(PropertyName = "id")]
38 | public string Id { get; set; }
39 |
40 | [JsonProperty(PropertyName = "name")]
41 | public string Name { get; set; }
42 |
43 | [JsonProperty(PropertyName = "overrides")]
44 | public string[] Overrides { get; set; }
45 |
46 | [JsonProperty(PropertyName = "schema_version")]
47 | public int SchemaVersion { get; set; }
48 |
49 | [JsonProperty(PropertyName = "tags")]
50 | public string[] Tags { get; set; }
51 |
52 | [JsonProperty(PropertyName = "applies_to")]
53 | public string[] AppliesTo { get; set; }
54 |
55 | [JsonProperty(PropertyName = "severity")]
56 | [JsonConverter(typeof(SeverityConverter))]
57 | public Severity Severity { get; set; }
58 |
59 | [JsonProperty(PropertyName = "description")]
60 | public string Description { get; set; }
61 |
62 | [JsonProperty(PropertyName = "recommendation")]
63 | public string Recommendation { get; set; }
64 |
65 | [JsonProperty(PropertyName = "rule_info")]
66 | public string RuleInfo { get; set; }
67 |
68 | [JsonProperty(PropertyName = "patterns")]
69 | public SearchPattern[] Patterns { get; set; }
70 |
71 | [JsonProperty(PropertyName = "conditions")]
72 | public SearchCondition[] Conditions { get; set; }
73 |
74 | [JsonProperty(PropertyName = "fix_its")]
75 | public CodeFix[] Fixes { get; set; }
76 |
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/cryptography/algorithm_implementation.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Cryptography: Algorithm Implementation",
4 | "id": "AI005700",
5 | "description": "Cryptography: Algorithm Implementation",
6 | "tags": [
7 | "Cryptography.Implementation"
8 | ],
9 | "severity": "important",
10 | "_comment": "Implementing a standard cryptographic algorithm",
11 | "patterns": [
12 | {
13 | "pattern": "5a827999",
14 | "type": "regex-word",
15 | "scopes": [ "code" ],
16 | "confidence": "high",
17 | "modifiers": []
18 | }
19 | ]
20 | },
21 | {
22 | "name": "Cryptography: Algorithm Implementation (SHA1)",
23 | "id": "AI005800",
24 | "description": "Cryptography: Algorithm Implementation (SHA1)",
25 | "tags": [
26 | "Cryptography.Implementation.SHA1"
27 | ],
28 | "severity": "important",
29 | "patterns": [
30 | {
31 | "pattern": "5a827999",
32 | "type": "string",
33 | "scopes": [ "code" ],
34 | "confidence": "high",
35 | "modifiers": [ "i" ]
36 | }
37 | ]
38 | },
39 | {
40 | "name": "Cryptography: Algorithm Implementation (MD5)",
41 | "id": "AI005900",
42 | "description": "Cryptography: Algorithm Implementation (MD5)",
43 | "tags": [
44 | "Cryptography.Implementation.MD5"
45 | ],
46 | "severity": "important",
47 | "patterns": [
48 | {
49 | "pattern": "242070db",
50 | "type": "string",
51 | "scopes": [ "code" ],
52 | "confidence": "high",
53 | "modifiers": [ "i" ]
54 | }
55 | ]
56 | },
57 | {
58 | "name": "Cryptography: Algorithm Implementation (SHA-256)",
59 | "id": "AI006000",
60 | "description": "Cryptography: Algorithm Implementation (SHA-256)",
61 | "tags": [
62 | "Cryptography.Implementation.SHA256"
63 | ],
64 | "severity": "important",
65 | "patterns": [
66 | {
67 | "pattern": "d807aa98",
68 | "type": "string",
69 | "scopes": [ "code" ],
70 | "confidence": "high",
71 | "modifiers": [ "i" ]
72 | }
73 | ]
74 | },
75 | {
76 | "name": "Cryptography: Algorithm Implementation (Keccak)",
77 | "id": "AI006100",
78 | "description": "Cryptography: Algorithm Implementation (Keccak)",
79 | "tags": [
80 | "Cryptography.Implementation.SHA256"
81 | ],
82 | "severity": "important",
83 | "patterns": [
84 | {
85 | "pattern": "800000000000808A",
86 | "type": "string",
87 | "scopes": [ "code" ],
88 | "confidence": "high",
89 | "modifiers": [ "i" ]
90 | }
91 | ]
92 | }
93 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/frameworks/PHP.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Detect Frameworks",
4 | "id": "AI023700",
5 | "description": "Detect well-known frameworks used",
6 | "recommendation": "",
7 | "applies_to": [ "php" ],
8 | "tags": [ "Framework.Development.PHP" ],
9 | "severity": "moderate",
10 | "_comment": "",
11 | "rule_info": "",
12 | "patterns": [
13 | {
14 | "pattern": "Laravel",
15 | "type": "regex",
16 | "scopes": [ "code", "comment" ],
17 | "modifiers": [ "i" ],
18 | "confidence": "high",
19 | "_comment": ""
20 | },
21 | {
22 | "pattern": "Symfony",
23 | "type": "regex",
24 | "scopes": [ "code", "comment" ],
25 | "modifiers": [ "i" ],
26 | "confidence": "high",
27 | "_comment": ""
28 | },
29 | {
30 | "pattern": "CodeIgniter",
31 | "type": "regex",
32 | "scopes": [ "code", "comment" ],
33 | "modifiers": [ "i" ],
34 | "confidence": "high",
35 | "_comment": ""
36 | },
37 | {
38 | "pattern": "Zend",
39 | "type": "regex",
40 | "scopes": [ "code", "comment" ],
41 | "modifiers": [ "i" ],
42 | "confidence": "high",
43 | "_comment": ""
44 | },
45 | {
46 | "pattern": "Fuelphp",
47 | "type": "regex",
48 | "scopes": [ "code", "comment" ],
49 | "modifiers": [ "i" ],
50 | "confidence": "high",
51 | "_comment": ""
52 | },
53 | {
54 | "pattern": "Slim",
55 | "type": "regex",
56 | "scopes": [ "code", "comment" ],
57 | "modifiers": [ "i" ],
58 | "confidence": "high",
59 | "_comment": ""
60 | },
61 | {
62 | "pattern": "Phalcon",
63 | "type": "regex",
64 | "scopes": [ "code", "comment" ],
65 | "modifiers": [ "i" ],
66 | "confidence": "high",
67 | "_comment": ""
68 | },
69 | {
70 | "pattern": "Aura",
71 | "type": "regex",
72 | "scopes": [ "code", "comment" ],
73 | "modifiers": [ "i" ],
74 | "confidence": "high",
75 | "_comment": ""
76 | },
77 | {
78 | "pattern": "Yii",
79 | "type": "regex",
80 | "scopes": [ "code", "comment" ],
81 | "modifiers": [ "i" ],
82 | "confidence": "high",
83 | "_comment": ""
84 | },
85 | {
86 | "pattern": "Cakephp",
87 | "type": "regex",
88 | "scopes": [ "code", "comment" ],
89 | "modifiers": [ "i" ],
90 | "confidence": "high",
91 | "_comment": ""
92 | }
93 | ]
94 | }
95 | ]
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | ## Security
2 |
3 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [many more](https://opensource.microsoft.com/).
4 |
5 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [definition](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below.
6 |
7 | ## Reporting Security Issues
8 |
9 | **Please do not report security vulnerabilities through public GitHub issues.**
10 |
11 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
12 |
13 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
14 |
15 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
16 |
17 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
18 |
19 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
20 | * Full paths of source file(s) related to the manifestation of the issue
21 | * The location of the affected source code (tag/branch/commit or direct URL)
22 | * Any special configuration required to reproduce the issue
23 | * Step-by-step instructions to reproduce the issue
24 | * Proof-of-concept or exploit code (if possible)
25 | * Impact of the issue, including how an attacker might exploit the issue
26 |
27 | This information will help us triage your report more quickly.
28 |
29 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
30 |
31 | ## Preferred Languages
32 |
33 | We prefer all communications to be in English.
34 |
35 | ## Policy
36 |
37 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
38 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/cloud_services/socialmedia.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Social Media: Facebook",
4 | "id": "AI003700",
5 | "description": "Social Media Facebook",
6 | "tags": [
7 | "CloudServices.SocialMedia.Facebook"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "facebook",
13 | "type": "string",
14 | "scopes": [ "code", "comment" ],
15 | "modifiers": [ "i" ],
16 | "confidence": "high"
17 | }
18 | ]
19 | },
20 | {
21 | "name": "Social Media: Twitter",
22 | "id": "AI003800",
23 | "description": "Social Media (Twitter)",
24 | "tags": [
25 | "CloudServices.SocialMedia.Twitter"
26 | ],
27 | "severity": "moderate",
28 | "patterns": [
29 | {
30 | "pattern": "twitter",
31 | "type": "string",
32 | "scopes": [ "code", "comment" ],
33 | "modifiers": [ "i" ],
34 | "confidence": "high"
35 | }
36 | ]
37 | },
38 | {
39 | "name": "Social Media: YouTube",
40 | "id": "AI003900",
41 | "description": "Social Media (YouTube)",
42 | "tags": [
43 | "CloudServices.SocialMedia.YouTube"
44 | ],
45 | "severity": "moderate",
46 | "patterns": [
47 | {
48 | "pattern": "youtube",
49 | "type": "string",
50 | "scopes": [ "code", "comment" ],
51 | "modifiers": [ "i" ],
52 | "confidence": "high"
53 | }
54 | ]
55 | },
56 | {
57 | "name": "Social Media: Instagram",
58 | "id": "AI004000",
59 | "description": "Social Media: Instagram",
60 | "tags": [
61 | "CloudServices.SocialMedia.Instagram"
62 | ],
63 | "severity": "moderate",
64 | "patterns": [
65 | {
66 | "pattern": "instagram",
67 | "type": "string",
68 | "scopes": [ "code", "comment" ],
69 | "modifiers": [ "i" ],
70 | "confidence": "high"
71 | }
72 | ]
73 | },
74 | {
75 | "name": "Social Media: Misc",
76 | "id": "AI004100",
77 | "description": "Social Media: Misc",
78 | "tags": [
79 | "CloudServices.SocialMedia.Misc"
80 | ],
81 | "severity": "moderate",
82 | "patterns": [
83 | {
84 | "pattern": "reddit|snapchat|whatsapp|tumblr|qzone|weibo|pinterest|ask\\.fm|flickr|linkedin|odnoklassniki|meetup",
85 | "type": "regex",
86 | "scopes": [ "code", "comment" ],
87 | "modifiers": [ "i" ],
88 | "confidence": "high"
89 | },
90 | {
91 | "pattern": "discord|diaspora|sociall\\.io|mastodon",
92 | "type": "regex",
93 | "scopes": [ "code", "comment" ],
94 | "modifiers": [ "i" ],
95 | "confidence": "high"
96 | }
97 | ]
98 | }
99 | ]
100 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/os/setenv.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "OS: Environment Variable (Write)",
4 | "id": "AI037500",
5 | "description": "OS: Environment Variable (Write)",
6 | "applies_to": [
7 | ],
8 | "tags": [
9 | "OS.Environment.Write"
10 | ],
11 | "severity": "moderate",
12 | "_comment": "",
13 | "patterns": [
14 | {
15 | "pattern": "setenv|putenv",
16 | "type": "regex-word",
17 | "scopes": [
18 | "code"
19 | ],
20 | "_comment": ""
21 | }
22 | ]
23 | },
24 | {
25 | "name": "OS: Environment Variable",
26 | "id": "AI037600",
27 | "description": "OS: Environment Variable",
28 | "applies_to": [
29 | ],
30 | "tags": [
31 | "OS.Environment.Windows.RegistryLocation"
32 | ],
33 | "severity": "moderate",
34 | "_comment": "Windows Registry location for environment variables",
35 | "patterns": [
36 | {
37 | "pattern": "System\\CurrentControlSet\\Control\\Session Manager\\Environment",
38 | "type": "substring",
39 | "scopes": [
40 | "code"
41 | ],
42 | "_comment": ""
43 | }
44 | ]
45 | },
46 | {
47 | "name": "OS: Environment Variable (Write)",
48 | "id": "AI037700",
49 | "description": "OS: Environment Variable (Write)",
50 | "applies_to": [
51 | "python"
52 | ],
53 | "tags": [
54 | "OS.Environment.Write"
55 | ],
56 | "severity": "moderate",
57 | "patterns": [
58 | {
59 | "pattern": "\\bos\\.environ.+=",
60 | "type": "regex",
61 | "scopes": [
62 | "code"
63 | ],
64 | "_comment": ""
65 | }
66 | ]
67 | },
68 | {
69 | "name": "OS: Environment Variable (Write)",
70 | "id": "AI037800",
71 | "description": "OS: Environment Variable (Write)",
72 | "applies_to": [
73 | "csharp"
74 | ],
75 | "tags": [
76 | "OS.Environment.Write"
77 | ],
78 | "severity": "moderate",
79 | "_comment": "",
80 | "patterns": [
81 | {
82 | "pattern": "SetEnvironmentVariable",
83 | "type": "string",
84 | "scopes": [
85 | "code"
86 | ],
87 | "_comment": ""
88 | }
89 | ]
90 | },
91 | {
92 | "name": "OS: Environment Variable (Write)",
93 | "id": "AI037900",
94 | "description": "OS: Environment Variable (Write)",
95 | "applies_to": [
96 | "powershell"
97 | ],
98 | "tags": [
99 | "OS.Environment.Write"
100 | ],
101 | "severity": "moderate",
102 | "_comment": "",
103 | "patterns": [
104 | {
105 | "pattern": "\\$env:.+=",
106 | "type": "regex",
107 | "scopes": [
108 | "code"
109 | ],
110 | "_comment": ""
111 | }
112 | ]
113 | }
114 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/data_types/secrets.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Data: Access Credentials",
4 | "id": "AI015800",
5 | "description": "Data: Access Credentials",
6 | "tags": [
7 | "Data.Sensitive.Credentials"
8 | ],
9 | "severity": "critical",
10 | "patterns": [
11 | {
12 | "pattern": "username|userid|passphrase|secret|password|credential|credentials|access_token",
13 | "type": "regex-word",
14 | "scopes": [
15 | "code"
16 | ],
17 | "confidence": "high",
18 | "modifiers": [ "i" ]
19 | },
20 | {
21 | "pattern": "\\.htpasswd|secret_key|private_key|authorized_keys|npmrc|\\.ssh",
22 | "type": "regex-word",
23 | "scopes": [
24 | "code"
25 | ],
26 | "confidence": "high",
27 | "modifiers": [ "i" ]
28 | },
29 | {
30 | "pattern": "auth_token|access_token|password|passwrd|client_credentials|client_*id|client_*secret",
31 | "type": "regex-word",
32 | "scopes": [ "code" ],
33 | "modifiers": [ "i" ],
34 | "confidence": "high"
35 | }
36 | ]
37 | },
38 | {
39 | "name": "Data: Embedded Secret",
40 | "id": "AI015900",
41 | "description": "Data: Embedded Secret",
42 | "tags": [
43 | "Data.Sensitive.Secret"
44 | ],
45 | "severity": "critical",
46 | "patterns": [
47 | {
48 | "pattern": "(secret|pass).*[a-f0-9]{30,}",
49 | "type": "regex",
50 | "scopes": [
51 | "code"
52 | ],
53 | "modifiers": [ "i" ],
54 | "confidence": "low"
55 | },
56 | {
57 | "pattern": "[\"'][a-f0-9]{30,}[\"']",
58 | "type": "regex",
59 | "scopes": [
60 | "code"
61 | ],
62 | "modifiers": [ "i" ],
63 | "confidence": "low"
64 | }
65 | ]
66 | },
67 | {
68 | "name": "Data: Secret",
69 | "id": "AI016000",
70 | "description": "Data: Secret",
71 | "tags": [
72 | "Data.Sensitive.Secret"
73 | ],
74 | "severity": "important",
75 | "patterns": [
76 | {
77 | "pattern": "(strictly|highly) confidential",
78 | "type": "regex",
79 | "scopes": [ "code", "comment" ],
80 | "modifiers": [ "i" ],
81 | "_comment": ""
82 | },
83 | {
84 | "pattern": "secret",
85 | "type": "string",
86 | "scopes": [ "code", "comment" ],
87 | "modifiers": [ "i" ]
88 | }
89 | ]
90 | },
91 | {
92 | "name": "Data: Product Key",
93 | "id": "AI016100",
94 | "description": "Data: Product Key",
95 | "tags": [
96 | "Data.Sensitive.ProductKey"
97 | ],
98 | "severity": "critical",
99 | "patterns": [
100 | {
101 | "pattern": "product[ ]*key",
102 | "type": "regex",
103 | "scopes": [ "code", "comment" ],
104 | "modifiers": [ "i" ],
105 | "_comment": ""
106 | }
107 | ]
108 | }
109 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/cryptography/random.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Crypgraphy: PRNG",
4 | "id": "AI010000",
5 | "description": "Crypgraphy: PRNG",
6 | "tags": [
7 | "Cryptography.Randomness.PRNG"
8 | ],
9 | "applies_to": [
10 | "c",
11 | "cpp"
12 | ],
13 | "severity": "critical",
14 | "patterns": [
15 | {
16 | "pattern": "DUAL_EC_DRBG",
17 | "type": "string",
18 | "scopes": [
19 | "code"
20 | ],
21 | "confidence": "high",
22 | "_comment": ""
23 | },
24 | {
25 | "pattern": "pseudoRandomBytes",
26 | "type": "string",
27 | "scopes": [
28 | "code"
29 | ],
30 | "confidence": "high",
31 | "_comment": ""
32 | },
33 | {
34 | "pattern": "rand|srand",
35 | "type": "regex-word",
36 | "scopes": [
37 | "code"
38 | ],
39 | "confidence": "low",
40 | "_comment": ""
41 | }
42 | ]
43 | },
44 | {
45 | "name": "Crypgraphy: PRNG",
46 | "id": "AI010100",
47 | "description": "Crypgraphy: PRNG",
48 | "tags": [
49 | "Cryptography.Randomness.PRNG"
50 | ],
51 | "applies_to": [
52 | "javascript"
53 | ],
54 | "severity": "critical",
55 | "patterns": [
56 | {
57 | "pattern": "(pseudo)?randombytes",
58 | "type": "string",
59 | "scopes": [
60 | "code"
61 | ],
62 | "modifiers": [ "i" ],
63 | "confidence": "high"
64 | }
65 | ]
66 | },
67 | {
68 | "name": "Crypgraphy: PRNG",
69 | "id": "AI010200",
70 | "description": "Crypgraphy: PRNG",
71 | "tags": [
72 | "Cryptography.Randomness.PRNG"
73 | ],
74 | "applies_to": [
75 | "java"
76 | ],
77 | "severity": "critical",
78 | "patterns": [
79 | {
80 | "pattern": "SecureRandom",
81 | "type": "string",
82 | "scopes": [
83 | "code"
84 | ],
85 | "confidence": "high"
86 | }
87 | ]
88 | },
89 | {
90 | "name": "Crypgraphy: PRNG",
91 | "id": "AI010300",
92 | "description": "Crypgraphy: PRNG",
93 | "tags": [
94 | "Cryptography.Randomness.PRNG"
95 | ],
96 | "applies_to": [
97 | "csharp"
98 | ],
99 | "severity": "critical",
100 | "patterns": [
101 | {
102 | "pattern": "RandomNumberGenerator",
103 | "type": "string",
104 | "scopes": [
105 | "code"
106 | ],
107 | "confidence": "high"
108 | }
109 | ]
110 | },
111 | {
112 | "name": "Crypgraphy: PRNG",
113 | "id": "AI010400",
114 | "description": "Crypgraphy: PRNG",
115 | "tags": [
116 | "Cryptography.Randomness.PRNG"
117 | ],
118 | "severity": "critical",
119 | "patterns": [
120 | {
121 | "pattern": "random",
122 | "type": "string",
123 | "scopes": [
124 | "code"
125 | ],
126 | "confidence": "low"
127 | }
128 | ]
129 | }
130 | ]
131 |
--------------------------------------------------------------------------------
/AppInspector/ErrorMessage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) Microsoft. All rights reserved.
2 | // Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3 |
4 |
5 | using System;
6 | using ApplicationInspector.Properties;
7 |
8 | namespace Microsoft.AppInspector
9 | {
10 | static public class ErrMsg
11 | {
12 | ///
13 | /// Maps enum values to resource strings for ensuring values exists at compile time
14 | ///
15 | public enum ID
16 | {
17 | ANALYZE_COMPRESSED_FILETYPE,
18 | ANALYZE_FILES_PROCESSED_PCNT,
19 | ANALYZE_NOPATTERNS,
20 | ANALYZE_NOSUPPORTED_FILETYPES,
21 | ANALYZE_UNCOMPRESSED_FILETYPE,
22 | ANALYZE_UNSUPPORTED_COMPR_TYPE,
23 | ANALYZE_FILESIZE_SKIPPED,
24 | ANALYZE_COMPRESSED_FILESIZE_WARN,
25 | ANALYZE_COMPRESSED_PROCESSING,
26 | ANALYZE_COMPRESSED_ERROR,
27 | ANALYZE_OUTPUT_FILE,
28 | ANALYZE_REPORTSIZE_WARN,
29 | CMD_PREPARING_REPORT,
30 | CMD_COMPLETED,
31 | CMD_CRITICAL_FILE_ERR,
32 | CMD_INVALID_ARG_VALUE,
33 | CMD_INVALID_FILE_OR_DIR,
34 | CMD_REPORT_DONE,
35 | CMD_REQUIRED_ARG_MISSING,
36 | CMD_RUNNING,
37 | CMD_INVALID_RULE_PATH,
38 | CMD_NORULES_SPECIFIED,
39 | TAGDIFF_NO_TAGS_FOUND,
40 | TAGDIFF_RESULTS_DIFFER,
41 | TAGDIFF_RESULTS_GAP,
42 | TAGDIFF_RESULTS_TEST_TYPE,
43 | TAGDIFF_SAME_FILE_ARG,
44 | TAGDIFF_RESULTS_SUCCESSS,
45 | TAGDIFF_RESULTS_FAIL,
46 | TAGTEST_RESULTS_NONE,
47 | TAGTEST_RESULTS_TAGS_FOUND,
48 | TAGTEST_RESULTS_TAGS_MISSING,
49 | TAGTEST_RESULTS_TEST_TYPE,
50 | TAGTEST_RESULTS_SUCCESS,
51 | TAGTEST_RESULTS_FAIL,
52 | VERIFY_RULE_FAILED,
53 | VERIFY_RULES_RESULTS_FAIL,
54 | VERIFY_RULES_RESULTS_SUCCESS,
55 | RUNTIME_ERROR_NAMED,
56 | RUNTIME_ERROR_UNNAMED,
57 | RUNTIME_ERROR_PRELOG,
58 | BROWSER_ENVIRONMENT_VAR,
59 | BROWSER_START_FAIL,
60 | BROWSER_START_SUCCESS
61 | };
62 |
63 | public static string GetString(ErrMsg.ID id)
64 | {
65 | string result = "";
66 | try
67 | {
68 | result = Resources.ResourceManager.GetString(id.ToString());
69 | }
70 | catch (Exception e)
71 | {
72 | string error = string.Format("Unable to locate requested string resource {0}", id);
73 | error += e.Message + "\n" + e.StackTrace;
74 | throw new Exception(error);
75 | }
76 |
77 | return result;
78 |
79 | }
80 |
81 | public static string FormatString(ErrMsg.ID id, params object[] parameters)
82 | {
83 | return String.Format(GetString(id), parameters);
84 | }
85 |
86 | public static string FormatString(ErrMsg.ID id, int value)
87 | {
88 | return String.Format(GetString(id), value);
89 | }
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/data_types/media.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Data: Audio File",
4 | "id": "AI015600",
5 | "description": "Data: Audio File",
6 | "tags": [
7 | "Data.Media.Audio"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "\\.(wma|wmv|asf|vp9|cr2|wav|mpeg|gsm|ogg|au|aiff|vox|aac|msv|dvf|flac|aifc|amz|atrac|m4a|m4p)",
13 | "type": "regex-word",
14 | "scopes": [
15 | "code",
16 | "comment"
17 | ],
18 | "modifiers": [ "i" ],
19 | "confidence": "high",
20 | "_comment": ""
21 | },
22 | {
23 | "pattern": "\\.(mp2|mp3|mp4|mpa|ra|rax|raw|smf|snd|sng|swa|hma|aac|ac3|eac3|Vorbis|pcm)",
24 | "type": "regex-word",
25 | "scopes": [
26 | "code",
27 | "comment"
28 | ],
29 | "modifiers": [ "i" ],
30 | "confidence": "high",
31 | "_comment": ""
32 | },
33 | {
34 | "pattern": "wma|wmv|asf|vp9|cr2|wav|mpeg|gsm|ogg|au|aiff|vox|aac|msv|dvf|flac|aifc|amz|atrac|m4a|m4p",
35 | "type": "regex-word",
36 | "scopes": [
37 | "code",
38 | "comment"
39 | ],
40 | "modifiers": [ "i" ],
41 | "confidence": "medium",
42 | "_comment": ""
43 | },
44 | {
45 | "pattern": "mp2|mp3|mp4|mpa|ra|rax|snd|sng|swa|hma|aac|ac3|eac3|Vorbis|pcm",
46 | "type": "regex-word",
47 | "scopes": [
48 | "code",
49 | "comment"
50 | ],
51 | "modifiers": [ "i" ],
52 | "confidence": "medium",
53 | "_comment": ""
54 | }
55 | ]
56 | },
57 | {
58 | "name": "Data: Video File",
59 | "id": "AI015700",
60 | "description": "Data: Video File",
61 | "tags": [
62 | "Data.Media.Video"
63 | ],
64 | "severity": "moderate",
65 | "patterns": [
66 | {
67 | "pattern": "\\.(avi|flv|mov|wmv|mp4|vob|hdv|ogg|oga|ogv|ogx)",
68 | "type": "regex-word",
69 | "scopes": [
70 | "code",
71 | "comment"
72 | ],
73 | "modifiers": [ "i" ],
74 | "confidence": "high",
75 | "_comment": ""
76 | },
77 | {
78 | "pattern": "\\.(mp4|m4v|f4v|f4a|m4b|m4r|f4b|mxf|op1a|op-atom)",
79 | "type": "regex-word",
80 | "scopes": [
81 | "code",
82 | "comment"
83 | ],
84 | "modifiers": [ "i" ],
85 | "confidence": "high",
86 | "_comment": ""
87 | },
88 | {
89 | "pattern": "avi|flv|mov|wmv|mp4|vob|hdv|ogg|oga|ogv|ogx",
90 | "type": "regex-word",
91 | "scopes": [
92 | "code",
93 | "comment"
94 | ],
95 | "modifiers": [ "i" ],
96 | "confidence": "medium",
97 | "_comment": ""
98 | },
99 | {
100 | "pattern": "mp4|m4v|f4v|f4a|m4b|m4r|f4b|mxf|op1a|op-atom",
101 | "type": "regex-word",
102 | "scopes": [
103 | "code",
104 | "comment"
105 | ],
106 | "modifiers": [ "i" ],
107 | "confidence": "medium",
108 | "_comment": ""
109 | }
110 | ]
111 | }
112 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/frameworks/logging.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Framework: Logging (Log4J)",
4 | "id": "AI021700",
5 | "description": "Framework: Logging (Log4J)",
6 | "applies_to": [
7 | "java"
8 | ],
9 | "tags": [
10 | "Framework.Development.Logging.Log4j"
11 | ],
12 | "severity": "moderate",
13 | "patterns": [
14 | {
15 | "pattern": "log4j",
16 | "type": "string",
17 | "scopes": [ "code" ],
18 | "confidence": "high",
19 | "_comment": ""
20 | }
21 | ]
22 | },
23 | {
24 | "name": "Framework: Logging (NLog)",
25 | "id": "AI021800",
26 | "description": "Framework: Logging (NLog)",
27 | "applies_to": [
28 | "csharp"
29 | ],
30 | "tags": [
31 | "Framework.Development.Logging.NLog"
32 | ],
33 | "severity": "moderate",
34 | "patterns": [
35 | {
36 | "pattern": "nlog",
37 | "type": "string",
38 | "scopes": [ "code" ],
39 | "confidence": "high",
40 | "_comment": ""
41 | }
42 | ]
43 | },
44 | {
45 | "name": "Framework: Logging (Serilog)",
46 | "id": "AI021900",
47 | "description": "Framework: Logging (Serilog)",
48 | "applies_to": [
49 | "csharp"
50 | ],
51 | "tags": [
52 | "Framework.Development.Logging.Serilog"
53 | ],
54 | "severity": "moderate",
55 | "patterns": [
56 | {
57 | "pattern": "serilog",
58 | "type": "string",
59 | "scopes": [ "code" ],
60 | "confidence": "high",
61 | "_comment": ""
62 | }
63 | ]
64 | },
65 | {
66 | "name": "Framework: Logging (log4net)",
67 | "id": "AI022000",
68 | "description": "Framework: Logging (log4net)",
69 | "applies_to": [
70 | "csharp"
71 | ],
72 | "tags": [
73 | "Framework.Development.Logging.Log4Net"
74 | ],
75 | "severity": "moderate",
76 | "patterns": [
77 | {
78 | "pattern": "log4net",
79 | "type": "string",
80 | "scopes": [ "code" ],
81 | "confidence": "high",
82 | "_comment": ""
83 | }
84 | ]
85 | },
86 | {
87 | "name": "Framework: Logging (ulog)",
88 | "id": "AI022100",
89 | "description": "Framework: Logging (ulog)",
90 | "applies_to": [
91 | "csharp"
92 | ],
93 | "tags": [
94 | "Framework.Development.Logging.ULog"
95 | ],
96 | "severity": "moderate",
97 | "patterns": [
98 | {
99 | "pattern": "ulog",
100 | "type": "string",
101 | "scopes": [ "code" ],
102 | "confidence": "high",
103 | "_comment": ""
104 | }
105 | ]
106 | },
107 | {
108 | "name": "Framework: Logging (Winston)",
109 | "id": "AI022200",
110 | "description": "Framework: Logging (Winston)",
111 | "applies_to": [
112 | "csharp"
113 | ],
114 | "tags": [
115 | "Framework.Development.Logging.Winston"
116 | ],
117 | "severity": "moderate",
118 | "patterns": [
119 | {
120 | "pattern": "winston",
121 | "type": "string",
122 | "scopes": [ "code" ],
123 | "confidence": "high",
124 | "_comment": ""
125 | }
126 | ]
127 | }
128 | ]
--------------------------------------------------------------------------------
/AppInspector/html/partials/_report_overview.liquid:
--------------------------------------------------------------------------------
1 |
2 |
Application Inspector Report
3 |
4 | Overview
5 | Welcome to the Microsoft Application Inspector Report.
6 | This report represents the analysis results for the specified source code. It contains
7 | features identified from a large variety of common characteristics including security
8 | and privacy characteristics, and other attributes to answer the question 'What is in the code?'.
9 | The tool can help validate purported component objectives using identifying patterns
10 | as well as detect feature changes between software component versions and even be used in automation scenarios.
11 |
12 |
13 |
14 |
Why it's different
15 | Knowing what is in your software is the first step to making informed choices about
16 | what actions are appropriate before allowing it to be include as part of your application in
17 | customer environments. Unlike a typical source code static analyzer,
18 | Application Inspector is judgement free, focusing instead on helping inform security
19 | and other scenarios by surfacing details that might otherwise go unnoticed.
20 |
21 |
22 |
23 |
Application Inspector Functions
24 |
25 |
26 |
27 | Analyze
28 | Scan source files for characteristics
29 |
30 |
31 |
32 | Tag Diff
33 | Compare identified tags (features) between source versions or components
34 |
35 |
36 |
37 |
38 |
39 | Tag Test
40 | Test source files for the presence of specific tag identifiers
41 |
42 |
43 |
44 | Tags
45 | Export Tags
46 |
47 |
48 |
49 | Verify
50 | Verify rules structure
51 |
52 |
53 |
54 |
55 |
56 |
Report Contents
57 | Feature are identified as "tags" found in the rule definitions which are customizable JSON files found under the 'rules' folder. Many characteristics are simply reported as
58 | "meta-data" which are not features in the code per se but are other attributes about the source that were detected which can be found in the Summary section.
59 |
60 |
61 |
64 |
65 |
66 |
67 | For more information, please visit our GitHub page to review
68 | the Application Inspector user guide, documentation, and source code.
69 |
70 |
--------------------------------------------------------------------------------
/AppInspector/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{ application_version }}
12 |
13 |
14 |
15 |
16 |
17 | Application Inspector
18 |
19 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | {% include "report_overview" %}
41 |
42 |
43 | {% include "report_summary" %}
44 |
45 |
46 | {% include "report_profile" %}
47 |
48 |
49 |
50 |
51 |
52 | {% include "file_listing" %}
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
67 |
68 |
--------------------------------------------------------------------------------
/AppInspector/rules/default/cryptography/hash_algorithm.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Cryptography: Hash Algorithm (SHA-256)",
4 | "id": "AI008700",
5 | "description": "Cryptography: Hash Algorithm Usage (SHA-256)",
6 | "tags": [
7 | "Cryptography.HashAlgorithm.SHA2"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "SHA-*(2|224|256|384|512)",
13 | "type": "regex",
14 | "scopes": [
15 | "code"
16 | ],
17 | "modifiers": [ "i" ],
18 | "confidence": "high"
19 | }
20 | ]
21 | },
22 | {
23 | "name": "Cryptography: Hash Algorithm (Legacy)",
24 | "id": "AI008800",
25 | "description": "Cryptography: Hash Algorithm (Legacy)",
26 | "tags": [
27 | "Cryptography.HashAlgorithm.Legacy"
28 | ],
29 | "severity": "moderate",
30 | "patterns": [
31 | {
32 | "pattern": "MD2|MD4|MD5|SHA-*(0|1)",
33 | "type": "regex-word",
34 | "scopes": [
35 | "code",
36 | "comment"
37 | ],
38 | "modifiers": [ "i" ],
39 | "confidence": "high"
40 | }
41 | ]
42 | },
43 | {
44 | "name": "Cryptography: Hash Algorithm (SHA-3)",
45 | "id": "AI008900",
46 | "description": "Cryptography: Hash Algorithm Usage (SHA-3)",
47 | "tags": [
48 | "Cryptography.HashAlgorithm.SHA3"
49 | ],
50 | "severity": "moderate",
51 | "patterns": [
52 | {
53 | "pattern": "SHA-*3|Keccak",
54 | "type": "regex",
55 | "scopes": [
56 | "code"
57 | ],
58 | "modifiers": [ "i" ],
59 | "confidence": "high"
60 | }
61 | ]
62 | },
63 | {
64 | "name": "Cryptography: Hash Algorithm (Misc)",
65 | "id": "AI009000",
66 | "description": "Cryptography: Hash Algorithm (Misc)",
67 | "tags": [
68 | "Cryptography.HashAlgorithm.Misc"
69 | ],
70 | "severity": "moderate",
71 | "patterns": [
72 | {
73 | "pattern": "RIPEMD|Blowfish|Twofish|Threefish|Serpent|HMAC|KeyedHashAlgorithm",
74 | "type": "regex",
75 | "scopes": [
76 | "code",
77 | "comment"
78 | ],
79 | "modifiers": [ "i" ],
80 | "confidence": "high"
81 | }
82 | ]
83 | },
84 | {
85 | "name": "Cryptography: Hash Algorithm",
86 | "id": "AI009100",
87 | "description": "Cryptography: Hash Algorithm Usage",
88 | "tags": [
89 | "Cryptography.HashAlgorithm.Other"
90 | ],
91 | "severity": "moderate",
92 | "patterns": [
93 | {
94 | "pattern": "HashAlgorithm|MessageDigest|DigestUtils",
95 | "type": "regex",
96 | "scopes": [
97 | "code"
98 | ],
99 | "modifiers": [ "i" ],
100 | "confidence": "high"
101 | }
102 | ]
103 | },
104 | {
105 | "name": "Cryptography: Hash Algorithm (General)",
106 | "id": "AI009200",
107 | "description": "Cryptography: Hash Algorithm (General)",
108 | "tags": [
109 | "Cryptography.HashAlgorithm.General"
110 | ],
111 | "severity": "moderate",
112 | "patterns": [
113 | {
114 | "pattern": "hash",
115 | "type": "regex",
116 | "scopes": [
117 | "code",
118 | "comment"
119 | ],
120 | "modifiers": [ "i" ],
121 | "confidence": "medium"
122 | }
123 | ]
124 | }
125 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/cloud_services/web_analytics.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Miscellaneous: Analytics Service",
4 | "id": "AI004200",
5 | "description": "Miscellaneous: Analytics Service",
6 | "tags": [
7 | "CloudServices.Web.Analytics.Facebook"
8 | ],
9 | "severity": "moderate",
10 | "patterns": [
11 | {
12 | "pattern": "analytics|tracker|tracking|tracking cookie|pixel url|tracking script",
13 | "type": "regex-word",
14 | "scopes": [ "code", "comment" ],
15 | "modifiers": [ "i" ],
16 | "confidence": "low"
17 | }
18 | ]
19 | },
20 | {
21 | "name": "Miscellaneous: Analytics Service (Facebook)",
22 | "id": "AI004300",
23 | "description": "Miscellaneous: Analytics Service (Facebook)",
24 | "tags": [
25 | "CloudServices.Web.Analytics.Facebook"
26 | ],
27 | "severity": "moderate",
28 | "patterns": [
29 | {
30 | "pattern": "connect.facebook.net",
31 | "type": "string",
32 | "scopes": [ "code" ],
33 | "modifiers": []
34 | }
35 | ]
36 | },
37 | {
38 | "name": "Miscellaneous: Analytics Service (Google GTag)",
39 | "id": "AI004400",
40 | "description": "Miscellaneous: Analytics Service (Google GTag)",
41 | "tags": [
42 | "CloudServices.Web.Analytics.Google.GTag"
43 | ],
44 | "severity": "moderate",
45 | "patterns": [
46 | {
47 | "pattern": "googletagmanager.com",
48 | "type": "string",
49 | "scopes": [ "code" ],
50 | "modifiers": []
51 | }
52 | ]
53 | },
54 | {
55 | "name": "Miscellaneous: Analytics Service (Bing)",
56 | "id": "AI004500",
57 | "description": "Miscellaneous: Analytics Service (Bing)",
58 | "tags": [
59 | "CloudServices.Web.Analytics.Microsoft.Bing"
60 | ],
61 | "severity": "moderate",
62 | "patterns": [
63 | {
64 | "pattern": "bat.bing.com",
65 | "type": "string",
66 | "scopes": [ "code" ],
67 | "modifiers": []
68 | }
69 | ]
70 | },
71 | {
72 | "name": "Miscellaneous: Analytics Service (Twitter)",
73 | "id": "AI004600",
74 | "description": "Miscellaneous: Analytics Service (Twitter)",
75 | "tags": [
76 | "CloudServices.Web.Analytics.Twitter"
77 | ],
78 | "severity": "moderate",
79 | "patterns": [
80 | {
81 | "pattern": "static.ads-twitter.com",
82 | "type": "string",
83 | "scopes": [ "code" ],
84 | "modifiers": []
85 | }
86 | ]
87 | },
88 | {
89 | "name": "Miscellaneous: Analytics Service (Outbrain)",
90 | "id": "AI004700",
91 | "description": "Miscellaneous: Analytics Service (Outbrain)",
92 | "tags": [
93 | "CloudServices.Web.Analytics.Outbrain"
94 | ],
95 | "severity": "moderate",
96 | "patterns": [
97 | {
98 | "pattern": "amplify.outbrain.com",
99 | "type": "string",
100 | "scopes": [ "code" ],
101 | "modifiers": []
102 | }
103 | ]
104 | },
105 | {
106 | "name": "Miscellaneous: Analytics Service (Pinterest)",
107 | "id": "AI004800",
108 | "description": "Miscellaneous: Analytics Service (Pinterest)",
109 | "tags": [
110 | "CloudServices.Web.Analytics.Pinterest"
111 | ],
112 | "severity": "moderate",
113 | "patterns": [
114 | {
115 | "pattern": "s.pinimg.com",
116 | "type": "string",
117 | "scopes": [ "code" ],
118 | "modifiers": []
119 | }
120 | ]
121 | }
122 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/data_types/financial.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Data: Financial (Account)",
4 | "id": "AI015000",
5 | "description": "Data: Financial (Account)",
6 | "tags": [
7 | "Data.Sensitive.Financial.BankAccount"
8 | ],
9 | "severity": "critical",
10 | "patterns": [
11 | {
12 | "pattern": "bank\\s*(acct|account)",
13 | "type": "regex-word",
14 | "scopes": [ "code", "comment" ],
15 | "modifiers": [ "i" ],
16 | "confidence": "high",
17 | "_comment": ""
18 | },
19 | {
20 | "pattern": "(checking|savings|chk|401k|roth)\\s*(account|acct)",
21 | "type": "regex-word",
22 | "scopes": [ "code" ],
23 | "modifiers": [ "i" ],
24 | "confidence": "high",
25 | "_comment": ""
26 | }
27 | ]
28 | },
29 | {
30 | "name": "Data: Financial (Income)",
31 | "id": "AI015100",
32 | "description": "Data: Financial (Income)",
33 | "tags": [
34 | "Data.Sensitive.Financial.General"
35 | ],
36 | "severity": "critical",
37 | "patterns": [
38 | {
39 | "pattern": "finances*|financial",
40 | "type": "regex",
41 | "scopes": [ "code" ],
42 | "modifiers": [ "i" ],
43 | "confidence": "high",
44 | "_comment": ""
45 | }
46 | ]
47 | },
48 | {
49 | "name": "Data: Financial (Currency)",
50 | "id": "AI015200",
51 | "description": "Data: Financial (Currency)",
52 | "tags": [
53 | "Data.Sensitive.Financial.Currency"
54 | ],
55 | "patterns": [
56 | {
57 | "pattern": "currency|usd|money|dollar|coins|euro|peso|deuch-mark|dinar|franc|krone|pound|rupee|shekel|yen",
58 | "type": "regex-word",
59 | "scopes": [ "code" ],
60 | "modifiers": [ "i" ],
61 | "confidence": "medium",
62 | "_comment": "Currencies"
63 | }
64 | ]
65 | },
66 | {
67 | "name": "Data: Financial (Credit Card)",
68 | "id": "AI015300",
69 | "description": "Data: Financial (Credit Card)",
70 | "tags": [
71 | "Data.Sensitive.Financial.CreditCard"
72 | ],
73 | "severity": "critical",
74 | "patterns": [
75 | {
76 | "pattern": "visa|americanexpress|amex|(master|discover|credit|debit)\\s*card",
77 | "type": "regex-word",
78 | "scopes": [ "code" ],
79 | "modifiers": [ "i" ],
80 | "confidence": "high",
81 | "_comment": ""
82 | }
83 | ]
84 | },
85 | {
86 | "name": "Data: Financial (Payroll)",
87 | "id": "AI015400",
88 | "description": "Data: Financial (Payroll)",
89 | "tags": [
90 | "Data.Sensitive.Financial.Payroll"
91 | ],
92 | "severity": "important",
93 | "patterns": [
94 | {
95 | "pattern": "pay-*roll|salary|salaries|stock",
96 | "type": "regex-word",
97 | "scopes": [ "code" ],
98 | "modifiers": [ "i" ],
99 | "confidence": "high",
100 | "_comment": ""
101 | }
102 | ]
103 | },
104 | {
105 | "name": "Data: Financial (Salesdata)",
106 | "id": "AI015500",
107 | "description": "Data: Financial (Salesdata)",
108 | "tags": [
109 | "Data.Sensitive.Financial.Salesdata"
110 | ],
111 | "severity": "critical",
112 | "patterns": [
113 | {
114 | "pattern": "sales",
115 | "type": "regex-word",
116 | "scopes": [ "code" ],
117 | "modifiers": [ "i" ],
118 | "confidence": "high",
119 | "_comment": "sales data or forecast"
120 | }
121 | ]
122 | }
123 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/test_frameworks/python_testing.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Testing Framework: AutoTest",
4 | "id": "AI051900",
5 | "description": "Testing Framework: AutoTest",
6 | "applies_to": [
7 | "python"
8 | ],
9 | "tags": [
10 | "Framework.Testing.AutoTest"
11 | ],
12 | "patterns": [
13 | {
14 | "pattern": "autotest",
15 | "type": "string",
16 | "scopes": [
17 | "code"
18 | ],
19 | "modifiers": [
20 | "i"
21 | ],
22 | "confidence": "high",
23 | "_comment": ""
24 | }
25 | ]
26 | },
27 | {
28 | "name": "Testing Framework: UnitTest",
29 | "id": "AI052000",
30 | "description": "Testing Framework: UnitTest",
31 | "applies_to": [
32 | "python"
33 | ],
34 | "tags": [
35 | "Framework.Testing.unittest"
36 | ],
37 | "patterns": [
38 | {
39 | "pattern": "unittest",
40 | "type": "string",
41 | "scopes": [
42 | "code"
43 | ],
44 | "confidence": "high"
45 | }
46 | ]
47 | },
48 | {
49 | "name": "Testing Framework: XPyUnit",
50 | "id": "AI052100",
51 | "description": "Testing Framework: XPyUnit",
52 | "applies_to": [
53 | "python"
54 | ],
55 | "tags": [
56 | "Framework.Testing.XPyUnit"
57 | ],
58 | "patterns": [
59 | {
60 | "pattern": "xpyunit",
61 | "type": "string",
62 | "scopes": [
63 | "code"
64 | ],
65 | "confidence": "high"
66 | }
67 | ]
68 | },
69 | {
70 | "name": "Testing Framework: DocTest",
71 | "id": "AI052200",
72 | "description": "Testing Framework: DocTest",
73 | "applies_to": [
74 | "python"
75 | ],
76 | "tags": [
77 | "Framework.Testing.Doctest"
78 | ],
79 | "patterns": [
80 | {
81 | "pattern": "doctest",
82 | "type": "string",
83 | "scopes": [
84 | "code"
85 | ],
86 | "confidence": "high"
87 | }
88 | ]
89 | },
90 | {
91 | "name": "Testing Framework: Nose",
92 | "id": "AI052300",
93 | "description": "Testing Framework: Nose",
94 | "applies_to": [
95 | "python"
96 | ],
97 | "tags": [
98 | "Framework.Testing.Nose"
99 | ],
100 | "patterns": [
101 | {
102 | "pattern": "import .*nose|nosetests|nose\\.run",
103 | "type": "regex",
104 | "scopes": [
105 | "code"
106 | ],
107 | "confidence": "high"
108 | }
109 | ]
110 | },
111 | {
112 | "name": "Testing Framework: PyTest",
113 | "id": "AI052400",
114 | "description": "Testing Framework: PyTest",
115 | "applies_to": [
116 | "python"
117 | ],
118 | "tags": [
119 | "Framework.Testing.PyTest"
120 | ],
121 | "patterns": [
122 | {
123 | "pattern": "pytest",
124 | "type": "string",
125 | "scopes": [
126 | "code"
127 | ],
128 | "confidence": "high"
129 | }
130 | ]
131 | },
132 | {
133 | "name": "Testing Framework: Should DSL",
134 | "id": "AI052500",
135 | "description": "Testing Framework: Should DSL",
136 | "applies_to": [
137 | "python"
138 | ],
139 | "tags": [
140 | "Framework.Testing.ShouldDSL"
141 | ],
142 | "patterns": [
143 | {
144 | "pattern": "should_dsl",
145 | "type": "string",
146 | "scopes": [
147 | "code"
148 | ],
149 | "confidence": "high"
150 | }
151 | ]
152 | }
153 | ]
--------------------------------------------------------------------------------
/AppInspector/rules/default/general/code_metrics.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Metric: Class Definition",
4 | "id": "AI025700",
5 | "description": "Metric: Classes Defined",
6 | "tags": [
7 | "Metric.Code.Class.Defined"
8 | ],
9 | "severity": "moderate",
10 | "applies_to": [ "csharp", "cpp", "javascript", "pyton", "vb", "rust", "ruby", "groovy", "php" ],
11 | "patterns": [
12 | {
13 | "pattern": "class",
14 | "type": "regex-word",
15 | "scopes": [ "code" ],
16 | "confidence": "high",
17 | "_comment": "langs defined to exclude css class reference vs class data structure which provides complexity/size insight"
18 | }
19 | ]
20 | },
21 | {
22 | "name": "Metric: Function Definition",
23 | "id": "AI025800",
24 | "description": "Metric: Function Defined",
25 | "tags": [
26 | "Metric.Code.Function.Defined"
27 | ],
28 | "severity": "moderate",
29 | "patterns": [
30 | {
31 | "pattern": "(def|function|fun) (.*)",
32 | "type": "regex-word",
33 | "scopes": [ "code" ],
34 | "confidence": "medium",
35 | "_comment": "doesn't detect a number of other potential patterns at present"
36 | }
37 | ]
38 | },
39 | {
40 | "name": "Metric: HTML Form Definition",
41 | "id": "AI025900",
42 | "description": "Metric: HTML Form Defined",
43 | "tags": [
44 | "Metric.Code.HTMLForm.Defined"
45 | ],
46 | "severity": "moderate",
47 | "_comment": "",
48 | "patterns": [
49 | {
50 | "pattern": "