Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Mocked data for learning

Introduction When a developer is learning a new method or technique, data is generally required to populate a development instance of a database; this article explains how. For all samples, a NuGet package Bogus was used to generate…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




Introduction



When a developer is learning a new method or technique, data is generally required to populate a development instance of a database; this article explains how.



For all samples, a NuGet package Bogus was used to generate data. Each time a sample project runs, the data remains the same, although there is an option to randomize it.



Sample data generator usage






Basics



Rather than creating fictitious data in a project, instead, create a class project that contains classes to generate data into models that also exist in the class project.



There are several options for using the class project. Create a test project in the same Visual Studio solution, copy the class project to another Visual Studio solution, or create a local NuGet package that can then be used no differently than any other NuGet package.






Considerations for data



In general, some ideas, person and product classes are a great starting point.






Examples



A developer wants to learn how to filter and order data. Executing ProductGenerator.Create(15) creates a list of 15 products followed by filtering Products by the UnitPrice property greater than 100, then ordering by UnitPrice.



The developer's goal is to learn how to write the code and by having predefined data saves the developer time to focus on learning rather than generating mocked data.




private static void DisplayHighValueProducts()
{
SpectreConsoleHelpers.PrintPink();

IOrderedEnumerable<Products> products = ProductGenerator.Create(15)
.Where(x => x.UnitPrice > 100)
.OrderByDescending(x => x.UnitPrice);

foreach (var p in products)
{
AnsiConsole.MarkupLine($"[bold green]{p.ProductName,-25}[/][yellow]{p.UnitPrice:C}[/]");
}
}






What if a predefined class does not fit when they need data? An option is to create a new class that uses an implicit operator as shown below.




public class Products
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public int? CategoryId { get; set; }
public decimal? UnitPrice { get; set; }
public short? UnitsInStock { get; set; }
public virtual Categories Category { get; set; }
public string CategoryName => Category.CategoryName;
public override string ToString() => ProductName;
}

public class ProductItem
{
public int Id { get; set; }
public string Name { get; set; }
public decimal? UnitPrice { get; set; }
public override string ToString() => Name;

public static implicit operator ProductItem(Products product) =>
new()
{
Id = product.ProductId,
Name = product.ProductName,
UnitPrice = product.UnitPrice
};
}






Example for implicit operator




List<ProductItem> products = ProductGenerator.Create(10)
.Select<Products, ProductItem>(p => p)
.ToList();









Anatomy of a generator



A generator, in this case, has a method to create a list of the desired model and a single instance of the model using the NuGet Bogus package.




public class ProductGenerator
{

public static List<Categories> GeneratedCategories { get; private set; } = [];

public static List<Products> Create(int count, bool random = false)
{
if (count <= 0)
return [];

// Seed control for reproducibility vs full randomness
Seed = !random ? new Random(338) : null;

// 1. Generate some categories
// Adjust categoryCount as you like or make it a parameter later.
const int categoryCount = 5;

var categoryFaker = new Faker<Categories>()
.StrictMode(true)
.RuleFor(c => c.CategoryId, f => f.IndexFaker + 1) // 1..categoryCount
.RuleFor(c => c.CategoryName, f => f.Commerce.Categories(1).First())
.RuleFor(c => c.Products, f => new HashSet<Products>());

GeneratedCategories = categoryFaker.Generate(categoryCount);

// 2. Generate products and link them too categories
var productFaker = new Faker<Products>()
.StrictMode(true)
.RuleFor(p => p.ProductId, f => f.IndexFaker + 1)
.RuleFor(p => p.ProductName, f => f.Commerce.ProductName())
.RuleFor(p => p.CategoryId, f => f.PickRandom(GeneratedCategories).CategoryId)
.RuleFor(p => p.UnitPrice, f => decimal.Parse(f.Commerce.Price(1, 500)))
.RuleFor(p => p.UnitsInStock, f => (short)f.Random.Int(0, 500))
.RuleFor(p => p.Category, (f, p) => GeneratedCategories.First(c => c.CategoryId == p.CategoryId));

var products = productFaker.Generate(count);

// 3. Back-fill the Category.Products collections so navigation
// works both ways in memory.
foreach (var category in GeneratedCategories)
{
var catProducts = products
.Where(p => p.CategoryId == category.CategoryId)
.ToList();

// Categories constructor already initializes Products to HashSet<Products>,
// but this makes sure it reflects the generated list.
category.Products = new HashSet<Products>(catProducts);
}

return products;
}

public static Categories CreateOne(bool random = false)
=> Create(1, random).FirstOrDefault()!.Category;
}






Careful consideration should be given when creating generators. For instance a Human model has a property of Address. There may be times when the Address model needs to have data generated outside of a Human. In this case unlike the products generator there is a case for an address generator.




public static class AddressGenerator
{
public static List<Address> Create(int count = 1)
{

Randomizer.Seed = new Random(337);

var faker = new Faker<Address>()
.RuleFor(a => a.Id, f => f.IndexFaker + 1)
.RuleFor(a => a.Street, f => f.Address.StreetName())
.RuleFor(a => a.City, f => f.Address.City())
.RuleFor(a => a.State, f => f.Address.State())
.RuleFor(a => a.ZipCode, f => f.Address.ZipCode())
.RuleFor(a => a.Country, f => f.Address.Country());

return faker.Generate(count);
}

public static Address CreateOne()
=> Create().FirstOrDefault()!;
}









Summary



Having data generators allows a developer to focus on learning rather than setting up mocked data.



Another use for data generators is for seeding databases. EF Core has UseAsyncSeeding for data seeding which a data generator can be use along with a property in appsettings.json to determine to use a data generator.






Source code



Source code




  • All code is fully documented

  • Has five generators

  • There are two console projects which uses the generators

  • For each generator has methods to serialize to JSON which can be helpful in simulating deserializing from a file.

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - Mocked data for learning
id: 4a721468-3503-4cca-a441-a8aab0842e2b
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-26
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-26"
        description = "YARA Signature for "
    strings:
        $str = "Mocked data for learning" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Mocked data for learning")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Mocked data for learning*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Mocked data for learning"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Mocked data for learning.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Mocked data for learning

Thematisch verwandte Begriffe: Mocked, data, learning · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-100618 | Capgo (capgo.app) is affected by an authorization flaw in the app icon …
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag