Skip to content

Commit bf4afe3

Browse files
authored
Feature/externalize mongo schema (#224)
* dependency updates * workflow update * workflow update * ignore config update * tool created * cleanup * remove reference to wiki * fixed an attribute name * starting to remove schema creation * removing schemas * removed static schemas * update supported platforms * record suppression feature * release notes update * documenation updates * package updates * dependency updates * action version update * action version update * documentdb compat * MongoTool doc update * minor logic update
1 parent 2f84d2b commit bf4afe3

File tree

68 files changed

+740
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+740
-625
lines changed

.github/workflows/build-ci.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ jobs:
1010

1111
infer-csharp-pr-comment:
1212
runs-on: ubuntu-latest
13-
if: github.event_name == 'pull_request'
13+
if: github.event_name == 'pull_request' && github.actor != 'dependabot'
1414
steps:
15+
- name: Actor
16+
run: |
17+
echo GITHUB_ACTOR
18+
echo ${{ github.actor }}
1519
- name: Dotnet Core Install
1620
uses: actions/setup-dotnet@v2
1721
with:
1822
dotnet-version: 6.*
1923
- name: Fetch Code
20-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2125
- name: Platform build win-x64
2226
run: dotnet publish --self-contained -c ReleaseWindows -o artifacts/win-x64 -r win-x64
2327
- name: Platform build linux-x64
@@ -58,7 +62,7 @@ jobs:
5862
with:
5963
dotnet-version: 6.*
6064
- name: Fetch Code
61-
uses: actions/checkout@v2
65+
uses: actions/checkout@v3
6266
- name: Platform build win-x64
6367
run: dotnet publish --self-contained -c ReleaseWindows -o artifacts -r win-x64
6468

@@ -71,7 +75,7 @@ jobs:
7175
with:
7276
dotnet-version: 6.*
7377
- name: Fetch Code
74-
uses: actions/checkout@v2
78+
uses: actions/checkout@v3
7579
- name: Platform build linux-x64
7680
run: dotnet publish --self-contained -c ReleaseLinux -o artifacts -r linux-x64
7781

@@ -85,9 +89,9 @@ jobs:
8589
dotnet-version: 6.*
8690
- name: Set up Docker Buildx
8791
id: buildx
88-
uses: docker/setup-buildx-action@v1
92+
uses: docker/setup-buildx-action@v2
8993
- name: Fetch Code
90-
uses: actions/checkout@v2
94+
uses: actions/checkout@v3
9195
- name: Platform build linux-x64
9296
run: dotnet publish --self-contained -c ReleaseLinux -o artifacts -r linux-x64
9397
- name: Build Docker Container
@@ -102,7 +106,7 @@ jobs:
102106
with:
103107
dotnet-version: 6.*
104108
- name: Fetch Code
105-
uses: actions/checkout@v2
109+
uses: actions/checkout@v3
106110
- name: Run Tests
107111
run: dotnet test --verbosity q
108112

@@ -111,7 +115,7 @@ jobs:
111115
runs-on: ubuntu-latest
112116
steps:
113117
- name: Fetch Code
114-
uses: actions/checkout@v2
118+
uses: actions/checkout@v3
115119
- name: Build Manual
116120
id: build_manual
117121
uses: xu-cheng/latex-action@v2
@@ -126,7 +130,7 @@ jobs:
126130
runs-on: ubuntu-latest
127131
steps:
128132
- name: Fetch Code
129-
uses: actions/checkout@v2
133+
uses: actions/checkout@v3
130134
- name: Build Release Notes
131135
id: build_release_notes
132136
uses: xu-cheng/latex-action@v2

.github/workflows/build-prerelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- uses: technote-space/workflow-conclusion-action@v2
3333
- name: Fetch Code
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v3
3535
if: env.WORKFLOW_CONCLUSION == 'failure'
3636
- name: Remove Prerelease Tag
3737
run: git push origin ':refs/tags/v${{ needs.create-tag.outputs.tag }}'

.github/workflows/publish-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
steps:
2727
- name: Set up Docker Buildx
2828
id: buildx
29-
uses: docker/setup-buildx-action@v1
29+
uses: docker/setup-buildx-action@v2
3030

3131

3232
- name: Login to GitHub Container Registry
@@ -43,7 +43,7 @@ jobs:
4343

4444

4545
- name: Fetch Code @ tag v${{ inputs.tag }}
46-
uses: actions/checkout@v2
46+
uses: actions/checkout@v3
4747
with:
4848
ref: refs/tags/v${{ inputs.tag }}
4949

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ artifacts/
1616
.build_tools/
1717
**/TestResults
1818

19-
**/DELETE*
19+
**/DELETE*
20+
**/launchSettings.json

Applications/CxAnalytixCLI/CxAnalytixCLI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Authors>Checkmarx</Authors>
1212
<Version>0.0.0</Version>
1313
<Description>CxAnalytix crawls and extracts vulnerability scan data from Checkmarx products.</Description>
14-
<Copyright>Copyright (c) 2019-2022 Checkmarx. All rights reserved.</Copyright>
14+
<Copyright>Copyright (c) 2019-2023 Checkmarx. All rights reserved.</Copyright>
1515
<PackageProjectUrl>https://github.com/checkmarx-ts/CxAnalytix/wiki</PackageProjectUrl>
1616
<PackageReadmeFile>$(SolutionDir)README.md</PackageReadmeFile>
1717
<RepositoryUrl>https://github.com/checkmarx-ts/CxAnalytix</RepositoryUrl>

Applications/CxAnalytixDaemon/CxAnalytixDaemon.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Authors>Checkmarx</Authors>
1010
<Version>0.0.0</Version>
1111
<Description>CxAnalytix crawls and extracts vulnerability scan data from Checkmarx products.</Description>
12-
<Copyright>Copyright (c) 2019-2022 Checkmarx. All rights reserved.</Copyright>
12+
<Copyright>Copyright (c) 2019-2023 Checkmarx. All rights reserved.</Copyright>
1313
<PackageProjectUrl>https://github.com/checkmarx-ts/CxAnalytix/wiki</PackageProjectUrl>
1414
<PackageReadmeFile>$(SolutionDir)README.md</PackageReadmeFile>
1515
<RepositoryUrl>https://github.com/checkmarx-ts/CxAnalytix</RepositoryUrl>
@@ -32,10 +32,9 @@
3232
</PropertyGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
36-
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0" />
37-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
38-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
35+
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
36+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
37+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
3938
</ItemGroup>
4039

4140
<ItemGroup>

Applications/CxAnalytixService/CxAnalytixService.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Authors>Checkmarx</Authors>
1313
<Version>0.0.0</Version>
1414
<Description>CxAnalytix crawls and extracts vulnerability scan data from Checkmarx products.</Description>
15-
<Copyright>Copyright (c) 2019-2022 Checkmarx. All rights reserved.</Copyright>
15+
<Copyright>Copyright (c) 2019-2023 Checkmarx. All rights reserved.</Copyright>
1616
<PackageProjectUrl>https://github.com/checkmarx-ts/CxAnalytix/wiki</PackageProjectUrl>
1717
<PackageReadmeFile>$(SolutionDir)README.md</PackageReadmeFile>
1818
<RepositoryUrl>https://github.com/checkmarx-ts/CxAnalytix</RepositoryUrl>
@@ -40,8 +40,7 @@
4040

4141

4242
<ItemGroup>
43-
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
44-
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
43+
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.4" />
4544
</ItemGroup>
4645

4746

CxAnalytix.sln

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SastTransformer", "XForm\Sa
8989
EndProject
9090
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "XForm\Common\Common.csproj", "{BE71BE3E-7591-4D62-BFB3-F77D7B57F12A}"
9191
EndProject
92-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CxOneTransformer", "XForm\CxOneTransformer\CxOneTransformer.csproj", "{9F56B86B-C692-4D85-BABB-735B969D2D4E}"
92+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CxOneTransformer", "XForm\CxOneTransformer\CxOneTransformer.csproj", "{9F56B86B-C692-4D85-BABB-735B969D2D4E}"
93+
EndProject
94+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Install", "Install", "{CDEFBA2F-FB11-44A9-AE7D-8317C42A830C}"
95+
EndProject
96+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoTool", "MongoTool\MongoTool.csproj", "{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}"
9397
EndProject
9498
Global
9599
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -891,6 +895,30 @@ Global
891895
{9F56B86B-C692-4D85-BABB-735B969D2D4E}.ReleaseWindows|x64.Build.0 = Release|Any CPU
892896
{9F56B86B-C692-4D85-BABB-735B969D2D4E}.ReleaseWindows|x86.ActiveCfg = Release|Any CPU
893897
{9F56B86B-C692-4D85-BABB-735B969D2D4E}.ReleaseWindows|x86.Build.0 = Release|Any CPU
898+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
899+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
900+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Debug|x64.ActiveCfg = Debug|Any CPU
901+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Debug|x64.Build.0 = Debug|Any CPU
902+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Debug|x86.ActiveCfg = Debug|Any CPU
903+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Debug|x86.Build.0 = Debug|Any CPU
904+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
905+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Release|Any CPU.Build.0 = Release|Any CPU
906+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Release|x64.ActiveCfg = Release|Any CPU
907+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Release|x64.Build.0 = Release|Any CPU
908+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Release|x86.ActiveCfg = Release|Any CPU
909+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.Release|x86.Build.0 = Release|Any CPU
910+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU
911+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU
912+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseLinux|x64.ActiveCfg = Release|Any CPU
913+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseLinux|x64.Build.0 = Release|Any CPU
914+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseLinux|x86.ActiveCfg = Release|Any CPU
915+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseLinux|x86.Build.0 = Release|Any CPU
916+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseWindows|Any CPU.ActiveCfg = Release|Any CPU
917+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseWindows|Any CPU.Build.0 = Release|Any CPU
918+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseWindows|x64.ActiveCfg = Release|Any CPU
919+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseWindows|x64.Build.0 = Release|Any CPU
920+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseWindows|x86.ActiveCfg = Release|Any CPU
921+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2}.ReleaseWindows|x86.Build.0 = Release|Any CPU
894922
EndGlobalSection
895923
GlobalSection(SolutionProperties) = preSolution
896924
HideSolutionNode = FALSE
@@ -930,6 +958,7 @@ Global
930958
{0788985B-731F-4BA5-A7E3-5C7996074B54} = {203A826C-286F-442C-B7B9-E43F806B8778}
931959
{BE71BE3E-7591-4D62-BFB3-F77D7B57F12A} = {203A826C-286F-442C-B7B9-E43F806B8778}
932960
{9F56B86B-C692-4D85-BABB-735B969D2D4E} = {203A826C-286F-442C-B7B9-E43F806B8778}
961+
{8DE4F60A-CD68-40D8-98F0-14E8C06406D2} = {CDEFBA2F-FB11-44A9-AE7D-8317C42A830C}
933962
EndGlobalSection
934963
GlobalSection(ExtensibilityGlobals) = postSolution
935964
SolutionGuid = {103FD3A6-4F85-4DC0-B65F-7E974EA202FE}

Libs/Configuration/Configuration.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Authors>Checkmarx</Authors>
99
<Version>0.0.0</Version>
1010
<Description>CxAnalytix crawls and extracts vulnerability scan data from Checkmarx products.</Description>
11-
<Copyright>Copyright (c) 2019-2022 Checkmarx. All rights reserved.</Copyright>
11+
<Copyright>Copyright (c) 2019-2023 Checkmarx. All rights reserved.</Copyright>
1212
<PackageProjectUrl>https://github.com/checkmarx-ts/CxAnalytix/wiki</PackageProjectUrl>
1313
<PackageReadmeFile>$(SolutionDir)README.md</PackageReadmeFile>
1414
<RepositoryUrl>https://github.com/checkmarx-ts/CxAnalytix</RepositoryUrl>
@@ -31,9 +31,9 @@
3131
</PropertyGroup>
3232

3333
<ItemGroup>
34-
<PackageReference Include="Autofac" Version="6.4.0" />
34+
<PackageReference Include="Autofac" Version="7.0.1" />
3535
<PackageReference Include="log4net" Version="2.0.15" />
36-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
36+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
3737
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
3838
</ItemGroup>
3939

Libs/Configuration/Impls/Config.cs

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
using CxAnalytix.Configuration.Utils;
33
using CxAnalytix.Exceptions;
44
using log4net;
5+
using log4net.Util;
56
using System;
7+
using System.Collections;
8+
using System.Collections.Generic;
69
using System.Configuration;
710
using System.IO;
811

912

13+
1014
namespace CxAnalytix.Configuration.Impls
1115
{
12-
public class Config
16+
public static class Config
1317
{
1418
private static System.Configuration.Configuration _cfgManager;
1519
private static ILog _log = LogManager.GetLogger(typeof (Config) );
@@ -32,62 +36,77 @@ static Config()
3236

3337
_cfgManager = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
3438

35-
if (OperatingSystem.IsWindows())
39+
40+
41+
if (OperatingSystem.IsWindows())
3642
EncryptSensitiveSections();
3743
else
3844
_log.Warn("This platform does not support encrypting credentials in the configuration file. Your credentials may be stored in plain text.");
3945

4046
var builder = new ContainerBuilder();
4147

42-
foreach(var sec in _cfgManager.Sections)
48+
foreach(var sec in _cfgManager.Sections.OnlyValid() )
4349
{
4450
builder.RegisterInstance(sec).As(sec.GetType()).ExternallyOwned();
4551
}
4652
_configDI = builder.Build();
4753

4854
}
4955

50-
public static T GetConfig<T>()
56+
private static IEnumerable<ConfigurationSection> OnlyValid(this ConfigurationSectionCollection elements)
5157
{
52-
return _configDI.Resolve<T>();
58+
List<ConfigurationSection> result = new();
59+
60+
for (int i = 0; i < elements.Count; i++)
61+
try
62+
{
63+
result.Add(elements[i]);
64+
}
65+
catch (ConfigurationErrorsException ex)
66+
{
67+
_log.Warn($"Configuration error: {ex.Message}");
68+
}
69+
70+
return result;
5371
}
5472

73+
public static T GetConfig<T>() => _configDI.Resolve<T>();
5574

56-
private static void EncryptSensitiveSections()
57-
{
58-
foreach (ConfigurationSection section in _cfgManager.Sections)
59-
{
60-
var attribs = section.GetType().GetCustomAttributes(typeof(SecureConfigSectionAttribute), true);
61-
62-
if (attribs != null && attribs.Length > 0)
63-
{
64-
bool found = false;
65-
foreach (SecureConfigSectionAttribute attribInst in attribs)
66-
{
67-
if (attribInst.IsPropSet(section.GetType(), section))
68-
{
69-
found = true;
70-
break;
71-
}
72-
}
73-
74-
if (!found)
75-
continue;
76-
}
77-
else
78-
continue;
79-
80-
if (!section.SectionInformation.IsProtected)
81-
{
82-
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
83-
section.SectionInformation.ForceSave = true;
84-
section.SectionInformation.ForceDeclaration(true);
85-
}
86-
}
75+
private static void EncryptSensitiveSections()
76+
{
77+
foreach (var section in _cfgManager.Sections.OnlyValid())
78+
{
79+
var attribs = section.GetType().GetCustomAttributes(typeof(SecureConfigSectionAttribute), true);
80+
81+
if (attribs != null && attribs.Length > 0)
82+
{
83+
bool found = false;
84+
foreach (SecureConfigSectionAttribute attribInst in attribs)
85+
{
86+
if (attribInst.IsPropSet(section.GetType(), section))
87+
{
88+
found = true;
89+
break;
90+
}
91+
}
92+
93+
if (!found)
94+
continue;
95+
}
96+
else
97+
continue;
98+
99+
if (!section.SectionInformation.IsProtected)
100+
{
101+
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
102+
section.SectionInformation.ForceSave = true;
103+
section.SectionInformation.ForceDeclaration(true);
104+
}
105+
}
87106

88107
_cfgManager.Save(ConfigurationSaveMode.Modified);
89-
}
108+
}
109+
90110

91-
92111
}
93112
}

0 commit comments

Comments
 (0)