add upgrade insecure request
This commit is contained in:
@@ -25,10 +25,11 @@ namespace HardHat.UnitTests
|
||||
FormAction = new HashSet<string>() { "http://*.example.com" },
|
||||
FrameAncestors = new HashSet<string>() { "http://*.example.com" },
|
||||
PluginTypes = new HashSet<string>() { "http://*.example.com" },
|
||||
Sandbox = SandboxOption.AllowPointerLock
|
||||
Sandbox = SandboxOption.AllowPointerLock,
|
||||
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;", 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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -91,6 +91,10 @@ namespace HardHat.Builders
|
||||
stringBuilder.Append(Constants.CSPDirectives.PluginTypes);
|
||||
stringBuilder.Append($" {string.Join(" ", policy.PluginTypes)}; ");
|
||||
}
|
||||
if(policy.UpgradeInsecureRequests)
|
||||
{
|
||||
stringBuilder.Append($"{Constants.CSPDirectives.UpgradeInsecureRequests}; ");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
internal const string FormAction = "form-action";
|
||||
internal const string FrameAncestors = "frame-ancestors";
|
||||
internal const string PluginTypes = "plugin-types";
|
||||
internal const string UpgradeInsecureRequests = "upgrade-insecure-requests";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,5 +68,6 @@ namespace HardHat
|
||||
/// </summary>
|
||||
public bool OnlySendReport { get; set; } = false;
|
||||
|
||||
public bool UpgradeInsecureRequests { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user