monogame-0001/0002/0003: MonoGame CWE-407 scan, 3 defects

monogame-0001: IntermediateWriter.WriteSharedResources writtenSharedResources
  List<string>.Contains in while loop O(R^2), fix: HashSet<string> MEDIUM
monogame-0002: IntermediateSerializer._scannedObjects List<object>.Contains
  per object during scan O(N^2), fix: HashSet<object> MEDIUM
monogame-0003: OpenAssetImporter._bones List<Node>.Contains in recursive
  tree import O(N*B), fix: HashSet<Node> MEDIUM
MOAD-0002 through 0005: CLEAN (single-threaded game framework, no secrets,
  no leaked context, no thundering herd)
This commit is contained in:
russell@unturf.com 2026-03-31 10:07:48 -04:00
parent 830b54936d
commit ec50768d5c
6 changed files with 347 additions and 0 deletions

View file

@ -0,0 +1,24 @@
--- a/MonoGame.Framework.Content.Pipeline/OpenAssetImporter.cs
+++ b/MonoGame.Framework.Content.Pipeline/OpenAssetImporter.cs
@@ -217,7 +217,7 @@ namespace Microsoft.Xna.Framework.Content.Pipeline
private Dictionary<string, Matrix> _deformationBones; // The names and offset matrices of all deformation bones.
private Node _rootBone; // The node that represents the root bone.
- private List<Node> _bones = new List<Node>(); // All nodes attached to the root bone.
+ private HashSet<Node> _bones = new HashSet<Node>(); // All nodes attached to the root bone.
private Dictionary<string, FbxPivot> _pivots; // The transformation pivots.
// XNA content
@@ -1115,7 +1115,7 @@ namespace Microsoft.Xna.Framework.Content.Pipeline
- private static void GetSubtree(Node node, List<Node> list)
+ private static void GetSubtree(Node node, ICollection<Node> collection)
{
Debug.Assert(node != null);
- Debug.Assert(list != null);
+ Debug.Assert(collection != null);
- list.Add(node);
+ collection.Add(node);
foreach (var child in node.Children)
- GetSubtree(child, list);
+ GetSubtree(child, collection);
}