Skip to content

feat: Threat Generation Support#21

Merged
Hacks4Snacks merged 8 commits into
mainfrom
hacks4snacks/threatgeneration
Jul 8, 2026
Merged

feat: Threat Generation Support#21
Hacks4Snacks merged 8 commits into
mainfrom
hacks4snacks/threatgeneration

Conversation

@Hacks4Snacks

Copy link
Copy Markdown
Owner

This PR is absolutely massive, but includes the following highlights.

  • Support for Threat Generation
  • Extended Core Rule set
  • BREAKING CHANGE to validation endpoints, renamed to analyze to better reflect the intent
  • Addressed serialization issue with opening .tm7 files created via tmforge in MTMT
  • Support for custom knowledge bases


private static (int Exit, string Stdout) Capture(Func<int> run)
{
StringWriter outWriter = new StringWriter();
private static (int Exit, string Stdout) Capture(Func<int> run)
{
StringWriter outWriter = new StringWriter();
StringWriter errorWriter = new StringWriter();
Comment on lines +157 to +164
foreach (string candidate in assembly.GetManifestResourceNames())
{
if (candidate.EndsWith(suffix, StringComparison.Ordinal))
{
resource = candidate;
break;
}
}
Comment on lines +304 to +310
foreach (Threat threat in model.AllThreatsDictionary.Values)
{
if (threat.Id > max)
{
max = threat.Id;
}
}
Comment on lines +130 to +137
foreach (object property in surface.Properties)
{
if (property is StringDisplayAttribute named &&
string.Equals(named.DisplayName, "Name", StringComparison.Ordinal))
{
return;
}
}
Comment on lines +456 to +463
foreach (ThreatStateDto state in dto.Threats ?? Array.Empty<ThreatStateDto>())
{
if (!string.IsNullOrEmpty(state.Id) &&
string.Equals(state.State, "Accepted", StringComparison.OrdinalIgnoreCase))
{
ThreatGenerator.Accept(model, state.Id, state.Justification ?? string.Empty);
}
}
public void Initialize()
{
this.WorkingDirectory = Path.Combine(Path.GetTempPath(), "tmforge-lint-" + Guid.NewGuid().ToString("N"));
this.WorkingDirectory = Path.Combine(Path.GetTempPath(), "tmforge-analyze-" + Guid.NewGuid().ToString("N"));
private string WorkingDirectory { get; set; } = string.Empty;

/// <summary>Gets the path of the model created by <see cref="NewModelWithFlow"/>.</summary>
private string ModelPath => Path.Combine(this.WorkingDirectory, "model.tm7");
[TestInitialize]
public void Initialize()
{
this.WorkingDirectory = Path.Combine(Path.GetTempPath(), "tmforge-threats-" + Guid.NewGuid().ToString("N"));
Comment on lines +138 to +144
foreach (JsonElement threat in data.GetProperty("threats").EnumerateArray())
{
if (threat.GetProperty("ruleId").GetString() == ruleId)
{
return true;
}
}
@Hacks4Snacks Hacks4Snacks merged commit b21d855 into main Jul 8, 2026
8 checks passed
This was referenced Jul 8, 2026
@Hacks4Snacks Hacks4Snacks deleted the hacks4snacks/threatgeneration branch July 9, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants