-
Notifications
You must be signed in to change notification settings - Fork 693
/
Wordlist.cs
60 lines (52 loc) · 2.16 KB
/
Wordlist.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.IO;
using System.Linq;
namespace RuriLib.Models
{
/// <summary>
/// Represents a file as a source of input data that needs to be tested against a Config by the Runner.
/// </summary>
public class Wordlist : Persistable<Guid>
{
/// <summary>The name of the Wordlist.</summary>
public string Name { get; set; }
/// <summary>The path where the file is stored on disk.</summary>
public string Path { get; set; }
/// <summary>The WordlistType as a string (since the WordlistTypes in the Environment file are editable).</summary>
public string Type { get; set; }
/// <summary>The purpose for which the Wordlist should be used.</summary>
public string Purpose { get; set; }
/// <summary>The total number of data lines of the file.</summary>
public int Total { get; set; }
/// <summary>If true, the Wordlist does not reside on the disk.</summary>
public bool Temporary { get; set; }
/// <summary>Needed for NoSQL deserialization.</summary>
public Wordlist() { }
/// <summary>
/// Creates an instance of a Wordlist.
/// </summary>
/// <param name="name">The name of the Wordlist</param>
/// <param name="path">The path to the file on disk</param>
/// <param name="type">The WordlistType as a string</param>
/// <param name="purpose">The purpose of the Wordlist</param>
/// <param name="countLines">Whether to enumerate the total number of data lines in the Wordlist</param>
/// <param name="temporary">If true, the Wordlist does not reside on the disk</param>
public Wordlist(string name, string path, string type, string purpose, bool countLines = true, bool temporary = false)
{
Name = name;
Path = path;
Type = type;
Purpose = purpose;
Total = 0;
Temporary = temporary;
if (countLines)
{
try
{
Total = File.ReadLines(path).Count();
}
catch { }
}
}
}
}