mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
68.98k stars 6.11k forks source link

Flowchart subgraph - too many nodes results in a node not rendered under it's subgraph section #5299

Open conan-chiles opened 4 months ago

conan-chiles commented 4 months ago

Description

hi, There seems to be a bug with flowchart and subgraphs, if too many nodes exist, results in a node expected to be under a subgraph rendered outside it's expected subgraph

any questions, please let me know, thanks

Steps to reproduce

example of a diagram with one too many nodes

keeping an eye on the node Scan_with_CPU["Scan with CPU"] should be under the subgraph Sensor_Visibility

for context, noticed while mapping out dependencies for some settings of an application

graph LR
    subgraph Behavior_based_Prevention
        Credential_Dumping["Credential Dumping"]
        NULL_Page_Allocation["NULL Page Allocation"]
        Heap_Spray_Preallocation["Heap Spray Preallocation"]
        SEH_Overwrite_Protection["SEH Overwrite Protection"]
        Code_Injection["Code Injection"]
        Volume_Shadow_Copy_Audit["Volume Shadow Copy - Audit"]
        Force_ASLR["Force ASLR"]
        Volume_Shadow_Copy_Protect["Volume Shadow Copy - Protect"]
        Force_DEP["Force DEP"]
    end
    subgraph Malware_Protection
        Suspicious_Scripts_and_Commands["Suspicious Scripts and Commands"]
        Vulnerable_Driver_Protection["Vulnerable Driver Protection"]
        Driver_Load_Prevention["Driver Load Prevention"]
    end
    subgraph Next_Gen_Antivirus
        Detect_on_Write["Detect on Write"]
        Microsoft_Office_File_Malicious_Macro_Removal["Microsoft Office File Malicious Macro Removal"]
        Sensor_Anti_malware_Prevention["Sensor Anti-malware - Prevention"]
        Quarantine_on_Write["Quarantine on Write"]
        Quarantine_on_Removable_Media["Quarantine on Removable Media"]
        Quarantine_Security_Center_Registration["Quarantine & Security Center Registration"]
        Sensor_Anti_malware_Detection["Sensor Anti-malware - Detection"]
    end
    subgraph Sensor_Visibility
        Scan_with_CPU["Scan with CPU"]
        Additional_User_Mode_Data_AUMD_["Additional User Mode Data (AUMD)"]
        BIOS_Deep_Visibility["BIOS Deep Visibility"]
        Engine_Full_Visibility_["Engine (Full Visibility)"]
        Redact_HTTP_Detections_Details["Redact HTTP Detections Details"]
        Extended_User_Mode_Data_XUMD_["Extended User Mode Data (XUMD)"]
        HTTP_Detections["HTTP Detections"]
        Script_Based_Execution_Monitoring["Script-Based Execution Monitoring"]
        Memory_Scanning["Memory Scanning"]
        Hardware_Enhanced_Exploit_Detection["Hardware-Enhanced Exploit Detection"]
        Interpreter_Only["Interpreter-Only"]
    end 

    Microsoft_Office_File_Malicious_Macro_Removal --> Quarantine_on_Write   

    Suspicious_Scripts_and_Commands --> Interpreter_Only
    Suspicious_Scripts_and_Commands --> Script_Based_Execution_Monitoring

    Suspicious_Scripts_and_Commands --> if_ARM64_req_Win11

    Scan_with_CPU --> Memory_Scanning
    Scan_with_CPU --> Additional_User_Mode_Data_AUMD_
    Scan_with_CPU --> Intel_CPU

    Credential_Dumping --> Additional_User_Mode_Data_AUMD_

    NULL_Page_Allocation --> Additional_User_Mode_Data_AUMD_

    Quarantine_on_Write --> Detect_on_Write

    Vulnerable_Driver_Protection --> Driver_Load_Prevention

    BIOS_Deep_Visibility --> physical_host  

    Heap_Spray_Preallocation --> Additional_User_Mode_Data_AUMD_    

    SEH_Overwrite_Protection --> Additional_User_Mode_Data_AUMD_    

    Redact_HTTP_Detections_Details --> not_windows_server   

    Code_Injection --> Additional_User_Mode_Data_AUMD_

    Quarantine_on_Removable_Media --> Quarantine_Security_Center_Registration

    HTTP_Detections --> not_windows_server

    Force_ASLR --> Additional_User_Mode_Data_AUMD_

    Volume_Shadow_Copy_Protect --> Volume_Shadow_Copy_Audit

    Force_DEP --> Additional_User_Mode_Data_AUMD_

    Script_Based_Execution_Monitoring --> if_ARM64_req_Win11
    Script_Based_Execution_Monitoring --> Quarantine_Security_Center_Registration

    Memory_Scanning --> physical_host
    Memory_Scanning --> Intel_CPU_SkyLake_or_later

    Detect_on_Write --> x86_64
    Sensor_Anti_malware_Prevention --> x86_64
    Suspicious_Scripts_and_Commands --> x86_64
    NULL_Page_Allocation --> x86_64
    Quarantine_on_Write --> x86_64
    BIOS_Deep_Visibility --> x86_64
    Engine_Full_Visibility_ --> x86_64
    Heap_Spray_Preallocation --> x86_64
    SEH_Overwrite_Protection --> x86_64

same diagram with one less node

removed SEH_Overwrite_Protection --> x86_64 Scan_with_CPU["Scan with CPU"] is now under the subgraph Sensor_Visibility

graph LR
    subgraph Behavior_based_Prevention
        Credential_Dumping["Credential Dumping"]
        NULL_Page_Allocation["NULL Page Allocation"]
        Heap_Spray_Preallocation["Heap Spray Preallocation"]
        SEH_Overwrite_Protection["SEH Overwrite Protection"]
        Code_Injection["Code Injection"]
        Volume_Shadow_Copy_Audit["Volume Shadow Copy - Audit"]
        Force_ASLR["Force ASLR"]
        Volume_Shadow_Copy_Protect["Volume Shadow Copy - Protect"]
        Force_DEP["Force DEP"]
    end
    subgraph Malware_Protection
        Suspicious_Scripts_and_Commands["Suspicious Scripts and Commands"]
        Vulnerable_Driver_Protection["Vulnerable Driver Protection"]
        Driver_Load_Prevention["Driver Load Prevention"]
    end
    subgraph Next_Gen_Antivirus
        Detect_on_Write["Detect on Write"]
        Microsoft_Office_File_Malicious_Macro_Removal["Microsoft Office File Malicious Macro Removal"]
        Sensor_Anti_malware_Prevention["Sensor Anti-malware - Prevention"]
        Quarantine_on_Write["Quarantine on Write"]
        Quarantine_on_Removable_Media["Quarantine on Removable Media"]
        Quarantine_Security_Center_Registration["Quarantine & Security Center Registration"]
        Sensor_Anti_malware_Detection["Sensor Anti-malware - Detection"]
    end
    subgraph Sensor_Visibility
        Scan_with_CPU["Scan with CPU"]
        Additional_User_Mode_Data_AUMD_["Additional User Mode Data (AUMD)"]
        BIOS_Deep_Visibility["BIOS Deep Visibility"]
        Engine_Full_Visibility_["Engine (Full Visibility)"]
        Redact_HTTP_Detections_Details["Redact HTTP Detections Details"]
        Extended_User_Mode_Data_XUMD_["Extended User Mode Data (XUMD)"]
        HTTP_Detections["HTTP Detections"]
        Script_Based_Execution_Monitoring["Script-Based Execution Monitoring"]
        Memory_Scanning["Memory Scanning"]
        Hardware_Enhanced_Exploit_Detection["Hardware-Enhanced Exploit Detection"]
        Interpreter_Only["Interpreter-Only"]
    end 

    Microsoft_Office_File_Malicious_Macro_Removal --> Quarantine_on_Write   

    Suspicious_Scripts_and_Commands --> Interpreter_Only
    Suspicious_Scripts_and_Commands --> Script_Based_Execution_Monitoring

    Suspicious_Scripts_and_Commands --> if_ARM64_req_Win11

    Scan_with_CPU --> Memory_Scanning
    Scan_with_CPU --> Additional_User_Mode_Data_AUMD_
    Scan_with_CPU --> Intel_CPU

    Credential_Dumping --> Additional_User_Mode_Data_AUMD_

    NULL_Page_Allocation --> Additional_User_Mode_Data_AUMD_

    Quarantine_on_Write --> Detect_on_Write

    Vulnerable_Driver_Protection --> Driver_Load_Prevention

    BIOS_Deep_Visibility --> physical_host  

    Heap_Spray_Preallocation --> Additional_User_Mode_Data_AUMD_    

    SEH_Overwrite_Protection --> Additional_User_Mode_Data_AUMD_    

    Redact_HTTP_Detections_Details --> not_windows_server   

    Code_Injection --> Additional_User_Mode_Data_AUMD_

    Quarantine_on_Removable_Media --> Quarantine_Security_Center_Registration

    HTTP_Detections --> not_windows_server

    Force_ASLR --> Additional_User_Mode_Data_AUMD_

    Volume_Shadow_Copy_Protect --> Volume_Shadow_Copy_Audit

    Force_DEP --> Additional_User_Mode_Data_AUMD_

    Script_Based_Execution_Monitoring --> if_ARM64_req_Win11
    Script_Based_Execution_Monitoring --> Quarantine_Security_Center_Registration

    Memory_Scanning --> physical_host
    Memory_Scanning --> Intel_CPU_SkyLake_or_later

    Detect_on_Write --> x86_64
    Sensor_Anti_malware_Prevention --> x86_64
    Suspicious_Scripts_and_Commands --> x86_64
    NULL_Page_Allocation --> x86_64
    Quarantine_on_Write --> x86_64
    BIOS_Deep_Visibility --> x86_64
    Engine_Full_Visibility_ --> x86_64
    Heap_Spray_Preallocation --> x86_64

Screenshots

with one too many image

with one less image

Code Sample

with one too many

https://mermaid-js.github.io/mermaid-live-editor/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SDrKxpDnTH3h_QYMFjoYs9mB1fr0PJiYiB3ghWv8lK3skCYwjOMq7Ys7Qrdn5zS8ZxDbQGXMeQxjkecLSNQ_G2wj3OaZBMuOVsfDufMOS1CCAEEAIIAe8I8mc0dXZ1vcTtiLITCvJJDCSGToQNZ6oeKNMXdVF0WOTWa-AdqTrM1t1C5Bxb__Lr15s2iRV9clnQKfcAIECbwwoCoA3hhTKK98XO_n-E_Tf6vd3_2Nr9Thw08Lcdt13gRg47c5fU9AUbh_ToWUmrjb-WPGbkMBAx0GLac419bDaMqqs810ugkbQRcpO7lpuqFVeZc14WWtqtHmxQowYFAbXXh6m9olYvjaDDca0KqnZHNCJRp2dt6gb0mwYRjEZ_Qc8oaIy9MusdfTfKY3mv1skl4Uhj8p6NF_OTj8yI_9l3qT58CBvonlKH3CloP-iVY9tPokQUtPKu999DR5pW_W-jYwOj356SOvrOfeadHbqGPav3jm189c0lRytXm0pmGOlKV7bpqKEX3FG7a7py4CX3FhuHx5uzpLTFAit8TlUMLaHDhrz9HDy-rAev0N2zeOh6DLncDn4oaIdt35bHhzv83nQ2hh67XYf4vDze36sTYfioH8l9U3p3JkVPTw-A4iBgy8fNjD9itQ0ruPW1APzZOYeO9fLphJ189PrD77x9-BETsosfHC9d0NAM6WIGz34XNPAI2cMdHA0emLxP1sKsuczxn9SfREsTuxJrfKWe4mfOzWOapOoX4uoyx4xPcyp_cnrPi0q8T3ht9XKjsijwqInk-NZbB-mv3wqzjLo

Setup

is consistent between the mermaid live preview using both Firefox and Edge, a VS Code Mermaid Preview extension (link below), and in GitHub issues markdown renderer

https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid

Suggested Solutions

No response

Additional Context

No response

ArtjomE commented 3 months ago

@conan-chiles here reported issue by me is the same #2291