mirror of
https://github.com/MISP/misp-galaxy.git
synced 2024-11-26 16:57:18 +00:00
Add [graph] cluster description
This commit is contained in:
parent
17066667f9
commit
1a5ccd23a2
3 changed files with 11 additions and 7 deletions
|
@ -24,7 +24,7 @@ def write_relations_table(cluster):
|
||||||
if cluster.relationships:
|
if cluster.relationships:
|
||||||
print(f"Writing {cluster.uuid}.md")
|
print(f"Writing {cluster.uuid}.md")
|
||||||
with open(os.path.join(relation_path, f"{cluster.uuid}.md"), "w") as index:
|
with open(os.path.join(relation_path, f"{cluster.uuid}.md"), "w") as index:
|
||||||
index.write(generate_relations_table(cluster.relationships))
|
index.write(generate_relations_table(cluster))
|
||||||
|
|
||||||
|
|
||||||
def get_cluster_relationships(cluster_data):
|
def get_cluster_relationships(cluster_data):
|
||||||
|
|
|
@ -119,8 +119,9 @@ document$.subscribe(function () {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let header = document.querySelector('h1').textContent;
|
let header = document.querySelector('h1').textContent;
|
||||||
const parentUUID = header.replace(/\s+/g, '-').charAt(0).toLowerCase() + header.replace(/\s+/g, '-').slice(1);
|
// const parentUUID = header.replace(/\s+/g, '-').charAt(0).toLowerCase() + header.replace(/\s+/g, '-').slice(1);
|
||||||
const Parent_Node = nodes.find(node => node.id.includes(parentUUID));
|
// console.log("Parent UUID: " + parentUUID);
|
||||||
|
const Parent_Node = nodes.find(node => node.id.includes(header));
|
||||||
|
|
||||||
var links = data.map(d => ({ source: d.source, target: d.target }));
|
var links = data.map(d => ({ source: d.source, target: d.target }));
|
||||||
|
|
||||||
|
@ -140,7 +141,7 @@ document$.subscribe(function () {
|
||||||
|
|
||||||
var simulation = d3.forceSimulation(nodes)
|
var simulation = d3.forceSimulation(nodes)
|
||||||
.force("link", d3.forceLink(links).id(d => d.id).distance(linkDistance))
|
.force("link", d3.forceLink(links).id(d => d.id).distance(linkDistance))
|
||||||
.force("charge", d3.forceManyBody().strength(-50).distanceMax(500))
|
.force("charge", d3.forceManyBody().strength(-70))
|
||||||
.force("center", d3.forceCenter(width / 2, height / 2))
|
.force("center", d3.forceCenter(width / 2, height / 2))
|
||||||
.alphaDecay(0.05); // A lower value, adjust as needed
|
.alphaDecay(0.05); // A lower value, adjust as needed
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,11 @@ def galaxy_transform_to_link(galaxy):
|
||||||
return f"[{galaxy.galaxy_name}](../../{galaxy_folder}/index.md)"
|
return f"[{galaxy.galaxy_name}](../../{galaxy_folder}/index.md)"
|
||||||
|
|
||||||
|
|
||||||
def generate_relations_table(relationships):
|
def generate_relations_table(cluster):
|
||||||
markdown = "|Cluster A | Galaxy A | Cluster B | Galaxy B | Level { .graph } |\n"
|
relationships = cluster.relationships
|
||||||
|
markdown = f"# {cluster.value} \n\n"
|
||||||
|
markdown += f"{cluster.description} \n\n"
|
||||||
|
markdown += "|Cluster A | Galaxy A | Cluster B | Galaxy B | Level { .graph } |\n"
|
||||||
markdown += "| --- | --- | --- | --- | --- |\n"
|
markdown += "| --- | --- | --- | --- | --- |\n"
|
||||||
for from_cluster, to_cluster, level in relationships:
|
for from_cluster, to_cluster, level in relationships:
|
||||||
from_galaxy = from_cluster.galaxy
|
from_galaxy = from_cluster.galaxy
|
||||||
|
@ -76,5 +79,5 @@ def generate_relations_table(relationships):
|
||||||
to_galaxy = to_cluster.galaxy
|
to_galaxy = to_cluster.galaxy
|
||||||
markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {cluster_transform_to_link(to_cluster, uuid=True)} | {galaxy_transform_to_link(to_galaxy)} | {level}\n"
|
markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {cluster_transform_to_link(to_cluster, uuid=True)} | {galaxy_transform_to_link(to_galaxy)} | {level}\n"
|
||||||
else:
|
else:
|
||||||
markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {to_cluster.value} | Unknown | {level}\n"
|
markdown += f"{cluster_transform_to_link(from_cluster, uuid=True)} | {galaxy_transform_to_link(from_galaxy)} | {to_cluster.value} ({to_cluster.uuid}) | Unknown | {level}\n"
|
||||||
return markdown
|
return markdown
|
||||||
|
|
Loading…
Reference in a new issue