-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3d68b2
commit de57355
Showing
33 changed files
with
13,108 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 O�uzhan Soykan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
AntiSamy .NET | ||
======== | ||
|
||
A .net standard library for performing configurable cleansing of HTML coming from untrusted sources. | ||
|
||
Another way of saying that could be: It's an API that helps you make sure that clients don't supply malicious cargo code in the HTML they supply for their profile, comments, etc., | ||
that get persisted on the server. The term "malicious code" in regards to web applications usually mean "JavaScript." Mostly, Cascading Stylesheets are only considered malicious | ||
when they invoke the JavaScript. However, there are many situations where "normal" HTML and CSS can be used in a malicious manner. | ||
|
||
How to Use | ||
---------- | ||
First, add the dependency from Nuget | ||
```powershall | ||
install-package AntiSamy | ||
``` | ||
|
||
```csharp | ||
Policy antiSamyPolicy = Policy.FromFile("<your_antisamy_xml_file_path>") | ||
AntiSamy antiSamy = new AntiSamy(); | ||
string yourDirtyInput = "<DIV><INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\"></DIV>"; | ||
AntiSamyResult result = antiSamy.Scan(yourDirtyInput, antiSamyPolicy); | ||
|
||
string cleanHtml = result.CleanHtml; | ||
IEnumerable<string> errorMessages = result.ErrorMessages; | ||
``` | ||
|
||
Referances | ||
---------- | ||
|
||
* [OWASP AntiSamy Project - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project](https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 1.0.{build} | ||
configuration: Release | ||
image: Visual Studio 2017 | ||
pull_requests: | ||
do_not_increment_build_number: true | ||
|
||
build_script: | ||
- ps: .\build.ps1 -experimental | ||
|
||
test: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#tool "nuget:?package=xunit.runner.console&version=2.3.0-beta4-build3742" | ||
|
||
#addin "nuget:?package=NuGet.Core" | ||
#addin "nuget:?package=Cake.ExtendedNuGet" | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
var projectName = "Stove"; | ||
var solution = "./" + projectName + ".sln"; | ||
|
||
var target = Argument("target", "Default"); | ||
var configuration = Argument("configuration", "Release"); | ||
var toolpath = Argument("toolpath", @"tools"); | ||
var branch = Argument("branch", EnvironmentVariable("APPVEYOR_REPO_BRANCH")); | ||
var nugetApiKey = EnvironmentVariable("nugetApiKey"); | ||
var isRelease = EnvironmentVariable("APPVEYOR_REPO_TAG") == "true"; | ||
var isPR = EnvironmentVariable("APPVEYOR_PULL_REQUEST_TITLE") != string.Empty; | ||
|
||
var testProjects = new List<Tuple<string, string[]>> | ||
{ | ||
new Tuple<string, string[]>("AntiSamy.Tests", new[] { "netcoreapp2.0" }) | ||
}; | ||
|
||
|
||
var nupkgPath = "nupkg"; | ||
var nupkgRegex = $"**/{projectName}*.nupkg"; | ||
var nugetPath = toolpath + "/nuget.exe"; | ||
var nugetQueryUrl = "https://www.nuget.org/api/v2/"; | ||
var nugetPushUrl = "https://www.nuget.org/api/v2/package"; | ||
var NUGET_PUSH_SETTINGS = new NuGetPushSettings | ||
{ | ||
ToolPath = File(nugetPath), | ||
Source = nugetPushUrl, | ||
ApiKey = nugetApiKey | ||
}; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASKS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Clean") | ||
.Does(() => | ||
{ | ||
Information("Current Branch is:" + EnvironmentVariable("APPVEYOR_REPO_BRANCH")); | ||
Information("Current Branch is:" + EnvironmentVariable("APPVEYOR_PULL_REQUEST_TITLE")); | ||
Information($"IsRelase: {isRelease}"); | ||
CleanDirectories("./src/**/bin"); | ||
CleanDirectories("./src/**/obj"); | ||
CleanDirectory(nupkgPath); | ||
}); | ||
|
||
Task("Restore-NuGet-Packages") | ||
.IsDependentOn("Clean") | ||
.Does(() => | ||
{ | ||
DotNetCoreRestore(solution); | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("Restore-NuGet-Packages") | ||
.Does(() => | ||
{ | ||
MSBuild(solution, new MSBuildSettings(){Configuration = configuration} | ||
.WithProperty("SourceLinkCreate","true")); | ||
}); | ||
|
||
Task("Run-Unit-Tests") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
foreach (Tuple<string, string[]> testProject in testProjects) | ||
{ | ||
foreach (string targetFramework in testProject.Item2) | ||
{ | ||
if(targetFramework == "net461") | ||
{ | ||
var testFile = GetFiles($"**/bin/{configuration}/{targetFramework}/{testProject.Item1}*.dll").First(); | ||
Information(testFile); | ||
XUnit2(testFile.ToString(), new XUnit2Settings { }); | ||
} | ||
else | ||
{ | ||
var testProj = GetFiles($"./test/**/*{testProject.Item1}.csproj").First(); | ||
DotNetCoreTest(testProj.FullPath, new DotNetCoreTestSettings { Configuration = "Release", Framework = targetFramework }); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
Task("Pack") | ||
.IsDependentOn("Run-Unit-Tests") | ||
.Does(() => | ||
{ | ||
var nupkgFiles = GetFiles(nupkgRegex); | ||
MoveFiles(nupkgFiles, nupkgPath); | ||
}); | ||
|
||
Task("NugetPublish") | ||
.IsDependentOn("Pack") | ||
.WithCriteria(() => branch == "master" && !AppVeyor.Environment.PullRequest.IsPullRequest) | ||
.Does(()=> | ||
{ | ||
foreach(var nupkgFile in GetFiles(nupkgRegex)) | ||
{ | ||
if(!IsNuGetPublished(nupkgFile, nugetQueryUrl)) | ||
{ | ||
Information("Publishing... " + nupkgFile); | ||
NuGetPush(nupkgFile, NUGET_PUSH_SETTINGS); | ||
} | ||
else | ||
{ | ||
Information("Already published, skipping... " + nupkgFile); | ||
} | ||
} | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASK TARGETS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Default") | ||
.IsDependentOn("Build") | ||
.IsDependentOn("Run-Unit-Tests") | ||
.IsDependentOn("Pack") | ||
.IsDependentOn("NugetPublish"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// EXECUTION | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
RunTarget(target); |
Oops, something went wrong.