Skip to content

Commit

Permalink
Project restructured for better CI process support. NuGet package gen…
Browse files Browse the repository at this point in the history
…eration introduced.
  • Loading branch information
kochetkov committed Feb 26, 2018
1 parent 7d5a505 commit b927968
Show file tree
Hide file tree
Showing 101 changed files with 99 additions and 76 deletions.
3 changes: 3 additions & 0 deletions scripts/build-libprotection.injections.cmd
@@ -0,0 +1,3 @@
dotnet --info
dotnet restore ..\sources\LibProtection.Injections
dotnet build -c Release ..\sources\LibProtection.Injections
12 changes: 12 additions & 0 deletions scripts/build-libprotection.playground.cmd
@@ -0,0 +1,12 @@
..\tools\nuget\nuget.exe restore ..\sources\LibProtection.PlayGround\LibProtection.PlayGround.sln

set vs2017dir=%programfiles(x86)%\Microsoft Visual Studio\2017
set msbuild="%vs2017dir%\Community\MSBuild\15.0\Bin\MSBuild.exe"
if not exist %msbuild% (
set msbuild="%vs2017dir%\Enterprise\MSBuild\15.0\Bin\MSBuild.exe"
)
if not exist %msbuild% (
set msbuild="%vs2017dir%\Professional\MSBuild\15.0\Bin\MSBuild.exe"
)

%msbuild% ..\sources\LibProtection.PlayGround\LibProtection.PlayGround.sln /t:Rebuild /p:Configuration=Release
18 changes: 0 additions & 18 deletions scripts/build.cmd

This file was deleted.

@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\LibProtection.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\..\LibProtection.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<None Include="..\..\submodules\libprotection-common\test-cases\**\*.*">
<None Include="..\..\..\submodules\libprotection-common\test-cases\**\*.*">
<Link>TestCases\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Expand Up @@ -136,8 +136,9 @@ internal static class TokenizationTestCases

private static IEnumerable TestCases(string languageName)
{
var casesDirectory =
Path.Combine(TestContext.CurrentContext.TestDirectory, "TestCases\\tokenization");
var casesDirectory = Path.Combine(
Path.GetDirectoryName(new Uri(typeof(TokenizationTests).Assembly.CodeBase).LocalPath),
"TestCases\\tokenization");

foreach (var fileName in Directory.GetFiles(casesDirectory, $"*.{languageName}"))
{
Expand Down
@@ -1,34 +1,34 @@
using System;
using System.Collections.Generic;

namespace LibProtection.Injections
{
public sealed class FilePath : RegexLanguageProvider
{
private const string DisallowedSymbols = @"<>:""/\\\|\?\*\x00-\x1f";

private FilePath() { }

protected override Enum ErrorTokenType => FilePathTokenType.Error;

protected override IEnumerable<RegexRule> MainModeRules { get; } = new[]
{
RegexRule.Token(@"[\\/]+", FilePathTokenType.Separator),
RegexRule.Token(@"[a-zA-Z]+[\$:](?=[\\/])", FilePathTokenType.DeviceID),
RegexRule.Token(@"[^" + DisallowedSymbols + "]+", FilePathTokenType.FSEntryName),
RegexRule.Token(@":+\$[^" + DisallowedSymbols + "]+", FilePathTokenType.NTFSAttribute),
RegexRule.Token($"[{DisallowedSymbols}]", FilePathTokenType.DisallowedSymbol),
};

public override bool TrySanitize(string text, Token context, out string sanitized)
{
sanitized = null;
return false;
}

protected override bool IsTrivial(Enum type, string text)
{
return (FilePathTokenType) type == FilePathTokenType.FSEntryName && !text.Contains("..");
}
}
using System;
using System.Collections.Generic;

namespace LibProtection.Injections
{
public sealed class FilePath : RegexLanguageProvider
{
private const string DisallowedSymbols = @"<>:""/\\\|\?\*\x00-\x1f";

private FilePath() { }

protected override Enum ErrorTokenType => FilePathTokenType.Error;

protected override IEnumerable<RegexRule> MainModeRules { get; } = new[]
{
RegexRule.Token(@"[\\/]+", FilePathTokenType.Separator),
RegexRule.Token(@"[a-zA-Z]+[\$:](?=[\\/])", FilePathTokenType.DeviceID),
RegexRule.Token(@"[^" + DisallowedSymbols + "]+", FilePathTokenType.FSEntryName),
RegexRule.Token(@":+\$[^" + DisallowedSymbols + "]+", FilePathTokenType.NTFSAttribute),
RegexRule.Token($"[{DisallowedSymbols}]", FilePathTokenType.DisallowedSymbol),
};

public override bool TrySanitize(string text, Token context, out string sanitized)
{
sanitized = null;
return false;
}

protected override bool IsTrivial(Enum type, string text)
{
return (FilePathTokenType) type == FilePathTokenType.FSEntryName && !text.Contains("..");
}
}
}
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp2.0;net40;net461</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\LibProtection.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\..\LibProtection.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<Antlr4UseCSharpGenerator>True</Antlr4UseCSharpGenerator>
Expand All @@ -17,7 +17,8 @@
<FileVersion>0.0.0</FileVersion>
<InformationalVersion>0.0.0</InformationalVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Libprotection.NET is a .NET version of LibProtection library — an alternative implementation of the standard functionality of the formatted and interpolated strings. It provides a realtime automatic protection from any class of the injection attacks, which belong to the most attacked languages (HTML, URL, JavaScript, SQL and the file paths are currently supported).</Description>
<Description>String formatting library with embedded automatic protection against injections attacks.</Description>
<Summary>Libprotection.NET is a .NET version of LibProtection library — an alternative implementation of the standard functionality of the formatted and interpolated strings. It provides a realtime automatic protection from any class of the injection attacks, which belong to the most attacked languages (HTML, URL, JavaScript, SQL and the file paths are currently supported).</Summary>
<PackageTags>injections, html, javascript, sql, path, url</PackageTags>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461' OR '$(TargetFramework)' == 'net40'">
Expand All @@ -27,19 +28,19 @@
<Compile Remove="SafeString.Formattable.cs" />
</ItemGroup>
<ItemGroup>
<Antlr4 Include="..\..\submodules\libprotection-common\grammars\HTMLLexer.g4" Link="Languages\Html\HTMLLexer.g4">
<Antlr4 Include="..\..\..\submodules\libprotection-common\grammars\HTMLLexer.g4" Link="Languages\Html\HTMLLexer.g4">
<Generator>MSBuild:Compile</Generator>
<CustomToolNamespace>LibProtection.Injections.Internals</CustomToolNamespace>
<Listener>False</Listener>
<Visitor>False</Visitor>
</Antlr4>
<Antlr4 Include="..\..\submodules\libprotection-common\grammars\JavaScriptCSharp.g4" Link="Languages\JavaScript\JavaScriptCSharp.g4">
<Antlr4 Include="..\..\..\submodules\libprotection-common\grammars\JavaScriptCSharp.g4" Link="Languages\JavaScript\JavaScriptCSharp.g4">
<Generator>MSBuild:Compile</Generator>
<CustomToolNamespace>LibProtection.Injections.Internals</CustomToolNamespace>
<Listener>False</Listener>
<Visitor>False</Visitor>
</Antlr4>
<Antlr4 Include="..\..\submodules\libprotection-common\grammars\SQLLexer.g4" Link="Languages\Sql\SQLLexer.g4">
<Antlr4 Include="..\..\..\submodules\libprotection-common\grammars\SQLLexer.g4" Link="Languages\Sql\SQLLexer.g4">
<Generator>MSBuild:Compile</Generator>
<CustomToolNamespace>LibProtection.Injections.Internals</CustomToolNamespace>
<Listener>False</Listener>
Expand Down
Expand Up @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibProtection.Injections",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibProtection.Injections.Tests", "LibProtection.Injections.Tests\LibProtection.Injections.Tests.csproj", "{023B2640-F991-4C71-8F5A-1629640F6678}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibProtection.TestSite", "LibProtection.TestSite\LibProtection.TestSite.csproj", "{477095F4-08A3-4520-B297-923E87319968}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -23,10 +21,6 @@ Global
{023B2640-F991-4C71-8F5A-1629640F6678}.Debug|Any CPU.Build.0 = Debug|Any CPU
{023B2640-F991-4C71-8F5A-1629640F6678}.Release|Any CPU.ActiveCfg = Release|Any CPU
{023B2640-F991-4C71-8F5A-1629640F6678}.Release|Any CPU.Build.0 = Release|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Debug|Any CPU.Build.0 = Debug|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Release|Any CPU.ActiveCfg = Release|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
31 changes: 31 additions & 0 deletions sources/LibProtection.Playground/LibProtection.Playground.sln
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibProtection.Playground", "LibProtection.Playground\LibProtection.Playground.csproj", "{477095F4-08A3-4520-B297-923E87319968}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibProtection.Injections", "..\LibProtection.Injections\LibProtection.Injections\LibProtection.Injections.csproj", "{C47CE6DC-EB08-4860-AF70-BB4155444862}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{477095F4-08A3-4520-B297-923E87319968}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Debug|Any CPU.Build.0 = Debug|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Release|Any CPU.ActiveCfg = Release|Any CPU
{477095F4-08A3-4520-B297-923E87319968}.Release|Any CPU.Build.0 = Release|Any CPU
{C47CE6DC-EB08-4860-AF70-BB4155444862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C47CE6DC-EB08-4860-AF70-BB4155444862}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C47CE6DC-EB08-4860-AF70-BB4155444862}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C47CE6DC-EB08-4860-AF70-BB4155444862}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {083E1955-A8E1-4996-AA73-33B0C4B9291C}
EndGlobalSection
EndGlobal
Expand Up @@ -13,8 +13,8 @@
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LibProtection.TestSite</RootNamespace>
<AssemblyName>LibProtection.TestSite</AssemblyName>
<RootNamespace>LibProtection.Playground</RootNamespace>
<AssemblyName>LibProtection.Playground</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
Expand Down Expand Up @@ -212,7 +212,12 @@
<DependentUpon>Site.Master</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\LibProtection.Injections\LibProtection.Injections\LibProtection.Injections.csproj">
<Project>{c47ce6dc-eb08-4860-af70-bb4155444862}</Project>
<Name>LibProtection.Injections</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Content Include="Scripts\jquery-1.10.2.min.map" />
Expand All @@ -223,12 +228,6 @@
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibProtection.Injections\LibProtection.Injections.csproj">
<Project>{20bba706-ba92-4b83-85d5-30e91c71ba13}</Project>
<Name>LibProtection.Injections</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down

0 comments on commit b927968

Please sign in to comment.