Compare commits
2 Commits
upgradeIns
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13f2ed4531 | ||
|
|
1f1c9ebd96 |
@@ -14,7 +14,7 @@ build_script:
|
|||||||
dotnet pack src\HardHat\HardHat.csproj --configuration Release --output ..\..\output /p:Version=0.0.1-build-$env:APPVEYOR_BUILD_NUMBER
|
dotnet pack src\HardHat\HardHat.csproj --configuration Release --output ..\..\output /p:Version=0.0.1-build-$env:APPVEYOR_BUILD_NUMBER
|
||||||
}
|
}
|
||||||
test_script:
|
test_script:
|
||||||
- ps: dotnet test src\HardHat.UnitTests\HardHat.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
|
- ps: dotnet test src\HardHat.UnitTests\HardHat.UnitTests.csproj
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: output\**.nupkg
|
- path: output\**.nupkg
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace HardHat.UnitTests
|
|||||||
FrameAncestors = new HashSet<string>() { "http://*.example.com" },
|
FrameAncestors = new HashSet<string>() { "http://*.example.com" },
|
||||||
PluginTypes = new HashSet<string>() { "http://*.example.com" },
|
PluginTypes = new HashSet<string>() { "http://*.example.com" },
|
||||||
Sandbox = SandboxOption.AllowPointerLock,
|
Sandbox = SandboxOption.AllowPointerLock,
|
||||||
UpgradeInsecureResponse = true
|
UpgradeInsecureRequests = true
|
||||||
|
|
||||||
});
|
});
|
||||||
Assert.Equal<string>(@"default-src 'self' 'none' http://*.example.com; script-src http://*.example.com; style-src http://*.example.com; img-src http://*.example.com; connect-src http://*.example.com; font-src http://*.example.com; object-src http://*.example.com; media-src http://*.example.com; child-src http://*.example.com; form-action http://*.example.com; frame-ancestors http://*.example.com; sandbox allow-pointer-lock; plugin-types http://*.example.com; upgrade-insecure-requests;", builder);
|
Assert.Equal<string>(@"default-src 'self' 'none' http://*.example.com; script-src http://*.example.com; style-src http://*.example.com; img-src http://*.example.com; connect-src http://*.example.com; font-src http://*.example.com; object-src http://*.example.com; media-src http://*.example.com; child-src http://*.example.com; form-action http://*.example.com; frame-ancestors http://*.example.com; sandbox allow-pointer-lock; plugin-types http://*.example.com; upgrade-insecure-requests;", builder);
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.msbuild" Version="2.3.1">
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||||
<PackageReference Include="Moq" Version="4.7.25" />
|
<PackageReference Include="Moq" Version="4.7.25" />
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ namespace HardHat.Builders
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(policy));
|
throw new ArgumentNullException(nameof(policy));
|
||||||
}
|
}
|
||||||
if(policy.DefaultSrc.Count > 0 && policy.DefaultSrc.Contains(CSPConstants.None))
|
|
||||||
{
|
|
||||||
//todo throw exception in this case
|
|
||||||
}
|
|
||||||
if (policy.DefaultSrc != null && policy.DefaultSrc.Count > 0)
|
if (policy.DefaultSrc != null && policy.DefaultSrc.Count > 0)
|
||||||
{
|
{
|
||||||
stringBuilder.Append(Constants.CSPDirectives.DefaultSrc);
|
stringBuilder.Append(Constants.CSPDirectives.DefaultSrc);
|
||||||
@@ -95,7 +91,7 @@ namespace HardHat.Builders
|
|||||||
stringBuilder.Append(Constants.CSPDirectives.PluginTypes);
|
stringBuilder.Append(Constants.CSPDirectives.PluginTypes);
|
||||||
stringBuilder.Append($" {string.Join(" ", policy.PluginTypes)}; ");
|
stringBuilder.Append($" {string.Join(" ", policy.PluginTypes)}; ");
|
||||||
}
|
}
|
||||||
if(policy.UpgradeInsecureResponse)
|
if(policy.UpgradeInsecureRequests)
|
||||||
{
|
{
|
||||||
stringBuilder.Append($"{Constants.CSPDirectives.UpgradeInsecureRequests}; ");
|
stringBuilder.Append($"{Constants.CSPDirectives.UpgradeInsecureRequests}; ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ namespace HardHat
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows the use of inline resources, such as inline <script> elements, javascript: URLs, inline event handlers, and inline <style> elements. You must include the single quotes.
|
/// Allows the use of inline resources, such as inline <script> elements, javascript: URLs, inline event handlers, and inline <style> elements. You must include the single quotes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string UnsafeInline = "unsafe-inline";
|
public const string UnsafeInline = "'unsafe-inline'";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows the use of eval() and similar methods for creating code from strings. You must include the single quotes.
|
/// Allows the use of eval() and similar methods for creating code from strings. You must include the single quotes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string UnsafeEval = "unsafe-eval";
|
public const string UnsafeEval = "'unsafe-eval'";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refers to the empty set; that is, no URLs match. The single quotes are required.
|
/// Refers to the empty set; that is, no URLs match. The single quotes are required.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -30,7 +30,7 @@ namespace HardHat
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The strict-dynamic source expression specifies that the trust explicitly given to a script present in the markup, by accompanying it with a nonce or a hash, shall be propagated to all the scripts loaded by that root script. At the same time, any whitelist or source expressions such as 'self' or 'unsafe-inline' will be ignored.
|
/// The strict-dynamic source expression specifies that the trust explicitly given to a script present in the markup, by accompanying it with a nonce or a hash, shall be propagated to all the scripts loaded by that root script. At the same time, any whitelist or source expressions such as 'self' or 'unsafe-inline' will be ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string StrictDynamic = "strict-dynamic";
|
public const string StrictDynamic = "'strict-dynamic'";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A whitelist for specific inline scripts using a cryptographic nonce (number used once). The server must generate a unique nonce value each time it transmits a policy. It is critical to provide an unguessable nonce, as bypassing a resource’s policy is otherwise trivial. See unsafe inline script for an example.
|
/// A whitelist for specific inline scripts using a cryptographic nonce (number used once). The server must generate a unique nonce value each time it transmits a policy. It is critical to provide an unguessable nonce, as bypassing a resource’s policy is otherwise trivial. See unsafe inline script for an example.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ namespace HardHat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool OnlySendReport { get; set; } = false;
|
public bool OnlySendReport { get; set; } = false;
|
||||||
|
|
||||||
public bool UpgradeInsecureResponse { get; set; } = false;
|
public bool UpgradeInsecureRequests { get; set; } = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,11 +204,6 @@ namespace HardHat
|
|||||||
Policy.Sandbox = sandboxOption ?? throw new ArgumentNullException(nameof(sandboxOption));
|
Policy.Sandbox = sandboxOption ?? throw new ArgumentNullException(nameof(sandboxOption));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ContentSecurityPolicyBuilder WithUpgradeInsecureResponse(bool enable = true)
|
|
||||||
{
|
|
||||||
Policy.UpgradeInsecureResponse = enable;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public ContentSecurityPolicy BuildPolicy() => Policy;
|
public ContentSecurityPolicy BuildPolicy() => Policy;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user