using System; using System.IO; using System.Linq; namespace RuriLib.Models { /// /// Represents a file as a source of input data that needs to be tested against a Config by the Runner. /// public class Wordlist { /// Needed for NoSQL storage. public Guid Id { get; set; } /// The name of the Wordlist. public string Name { get; set; } /// The path where the file is stored on disk. public string Path { get; set; } /// The WordlistType as a string (since the WordlistTypes in the Environment file are editable). public string Type { get; set; } /// The purpose for which the Wordlist should be used. public string Purpose { get; set; } /// The total number of data lines of the file. public int Total { get; set; } /// Needed for NoSQL deserialization. public Wordlist() { } /// /// Creates an instance of a Wordlist. /// /// The name of the Wordlist /// The path to the file on disk /// The WordlistType as a string /// The purpose of the Wordlist /// Whether to enumerate the total number of data lines in the Wordlist public Wordlist(string name, string path, string type, string purpose, bool countLines = true) { Name = name; Path = path; Type = type; Purpose = purpose; Total = 0; if (countLines) { try { Total = File.ReadLines(path).Count(); } catch { } } } } }