Skip to content

Commit

Permalink
Remove backups (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
iosebyte authored Sep 4, 2019
1 parent 038ec70 commit e9a0bde
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 348 deletions.
96 changes: 0 additions & 96 deletions FOCA/Analysis/HttpMap/HttpMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,12 @@ public enum SearchStatus
[JsonIgnore]
public int Id { get; set; }

public ThreadSafeList<HttpMapTypesFiles> HttpMapTypesFiles { get; set; }

/// <summary>
/// Modified filenames for backup files search actions
/// </summary>
[JsonIgnore]
public ThreadSafeList<string> BackupModifiedFilenames { get; set; }

/// <summary>
/// Modified filenames for backup files search actions
/// </summary>
public ThreadSafeList<string> Pathfilenames { get; set; } = new ThreadSafeList<string>();

/// <summary>
/// Backup Files found
/// </summary>
public ThreadSafeList<BackUpFile> Backups { get; set; }

/// <summary>
/// Documents found
/// </summary>
Expand All @@ -66,27 +54,6 @@ public enum SearchStatus
/// </summary>
public ThreadSafeList<string> Folders { get; set; }

/// <summary>
/// List of directories with insecure methods enabled
/// </summary>
public ThreadSafeList<FuzzMethodFolderObject> InsecureMethodFoldersFound;

/// <summary>
/// List of directories where a public .listing file was found
/// </summary>
public ThreadSafeList<string> ListingFilesFound;

/// <summary>
/// List of directories where the .listing file has already been tested
/// </summary>
[JsonIgnore]
public ThreadSafeList<string> ListingFilesTest;

/// <summary>
/// List of open directories
/// </summary>
public ThreadSafeList<FuzzOpenFolderObject> OpenFoldersFound;

/// <summary>
/// List of endpoints where parameters were found
/// </summary>
Expand All @@ -97,11 +64,6 @@ public enum SearchStatus
/// </summary>
public SearchStatus SearchingAllLinks;

/// <summary>
/// Backups search status
/// </summary>
public SearchStatus SearchingBackUps;

/// <summary>
/// Insecure methods search status
/// </summary>
Expand All @@ -127,18 +89,12 @@ public enum SearchStatus
/// </summary>
public HttpMap()
{
Backups = new ThreadSafeList<BackUpFile>();
Documents = new ThreadSafeList<string>();
Files = new ThreadSafeList<string>();
BackupModifiedFilenames = new ThreadSafeList<string>();
Folders = new ThreadSafeList<string>();
InsecureMethodFoldersFound = new ThreadSafeList<FuzzMethodFolderObject>();
ListingFilesFound = new ThreadSafeList<string>();
ListingFilesTest = new ThreadSafeList<string>();
OpenFoldersFound = new ThreadSafeList<FuzzOpenFolderObject>();
Parametrized = new ThreadSafeList<string>();

SearchingBackUps = SearchStatus.NotInitialized;
SearchingAllLinks = SearchStatus.NotInitialized;
SearchingMethods = SearchStatus.NotInitialized;
SearchingOpenFolders = SearchStatus.NotInitialized;
Expand Down Expand Up @@ -266,26 +222,6 @@ public void AddUrl(string url)
#endif
}

/// <summary>
/// Add URL to the listing record
/// </summary>
/// <param name="url"></param>
public void AddFileListingTest(string url)
{
if (!ListingFilesTest.Contains(url))
ListingFilesTest.Add(url);
}

/// <summary>
/// Add a backup file if it doesn't exist
/// </summary>
/// <param name="backupFile"></param>
public void AddBackUp(BackUpFile backupFile)
{
if (!ExistBackUp(backupFile))
Backups.Add(backupFile);
}

/// <summary>
/// Remove parameters and DOM elements from a given URL
/// </summary>
Expand Down Expand Up @@ -637,16 +573,6 @@ var extension in
}
}

/// <summary>
/// Check if a backup file was already added to the project
/// </summary>
/// <param name="backUpFile"></param>
/// <returns></returns>
private bool ExistBackUp(BackUpFile backUpFile)
{
return Backups.Any(b => b.Url.Equals(backUpFile.Url));
}

/// <summary>
/// Check if a file already exists in the project
/// </summary>
Expand Down Expand Up @@ -702,23 +628,13 @@ protected virtual void Dispose(bool disposing)
Documents.Dispose();
Folders.Dispose();
Parametrized.Dispose();
ListingFilesTest.Dispose();
ListingFilesFound.Dispose();
Backups.Dispose();
OpenFoldersFound.Dispose();
InsecureMethodFoldersFound.Dispose();
}

Files = null;
BackupModifiedFilenames = null;
Documents = null;
Folders = null;
Parametrized = null;
ListingFilesTest = null;
ListingFilesFound = null;
Backups = null;
OpenFoldersFound = null;
InsecureMethodFoldersFound = null;

_disposedValue = true;
}
Expand All @@ -731,16 +647,4 @@ public void Dispose()

#endregion
}

public struct BackUpFile
{
public HttpStatusCode Code;
public string Url;

public BackUpFile(string url, HttpStatusCode code)
{
Url = url;
Code = code;
}
}
}
8 changes: 2 additions & 6 deletions FOCA/Database/Controllers/HttpMapController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq;
using FOCA.Analysis.HttpMap;
using FOCA.Analysis.HttpMap;
using FOCA.Database.Entities;
using FOCA.ModifiedComponents;
using System.Linq;

namespace FOCA.Database.Controllers
{
Expand All @@ -11,15 +11,11 @@ public void Save(HttpMap item)
{
using (FocaContextDb context = new FocaContextDb())
{
var listBackups =
item.Backups.Select(x => new HttpMapTypesFiles() { IdHttMap = item.Id, IdType = 1, Value = x.Url }).ToList();

var listDocuments = item.Documents.Select(x => new HttpMapTypesFiles() { IdHttMap = item.Id, IdType = 2, Value = x.ToString() }).ToList();
var listFiles = item.Files.Select(x => new HttpMapTypesFiles() { IdHttMap = item.Id, IdType = 3, Value = x.ToString() }).ToList();
var listFolders = item.Folders.Select(x => new HttpMapTypesFiles() { IdHttMap = item.Id, IdType = 4, Value = x.ToString() }).ToList();
var listParametrized = item.Parametrized.Select(x => new HttpMapTypesFiles() { IdHttMap = item.Id, IdType = 5, Value = x.ToString() }).ToList();

context.HttpMapTypesFiles.AddRange(listBackups);
context.HttpMapTypesFiles.AddRange(listDocuments);
context.HttpMapTypesFiles.AddRange(listFiles);
context.HttpMapTypesFiles.AddRange(listFolders);
Expand Down
2 changes: 0 additions & 2 deletions FOCA/Database/Entities/HttpMapTypesFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ public class HttpMapTypesFiles

public string Value { get; set; }

public string Extension { get; set; }

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace FOCA.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class RemoveUnusedBackupSupport : DbMigration
{
public override void Up()
{
DropForeignKey("dbo.HttpMapTypesFiles", "HttpMap_Id", "dbo.HttpMaps");
DropIndex("dbo.HttpMapTypesFiles", new[] { "HttpMap_Id" });
DropColumn("dbo.HttpMapTypesFiles", "Extension");
DropColumn("dbo.HttpMapTypesFiles", "HttpMap_Id");
}

public override void Down()
{
AddColumn("dbo.HttpMapTypesFiles", "HttpMap_Id", c => c.Int());
AddColumn("dbo.HttpMapTypesFiles", "Extension", c => c.String());
CreateIndex("dbo.HttpMapTypesFiles", "HttpMap_Id");
AddForeignKey("dbo.HttpMapTypesFiles", "HttpMap_Id", "dbo.HttpMaps", "Id");
}
}
}

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions FOCA/FOCA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@
</Compile>
<Compile Include="Database\Entities\IPs.cs" />
<Compile Include="Database\Entities\Limits.cs" />
<Compile Include="Database\Migrations\201908230648106_RemoveUnusedBackupSupport.cs" />
<Compile Include="Database\Migrations\201908230648106_RemoveUnusedBackupSupport.Designer.cs">
<DependentUpon>201908230648106_RemoveUnusedBackupSupport.cs</DependentUpon>
</Compile>
<Compile Include="Utilities\Log.cs" />
<Compile Include="Utilities\NetRange.cs" />
<Compile Include="Utilities\OperatingSystem.cs" />
Expand Down Expand Up @@ -501,6 +505,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Database\Migrations\201908230648106_RemoveUnusedBackupSupport.resx">
<DependentUpon>201908230648106_RemoveUnusedBackupSupport.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormAddAltDNSParser.resx">
<DependentUpon>FormAddAltDNSParser.cs</DependentUpon>
</EmbeddedResource>
Expand Down
Loading

0 comments on commit e9a0bde

Please sign in to comment.