Skip to content

Commit

Permalink
Merge pull request #4 from magicsword-io/nextra
Browse files Browse the repository at this point in the history
Adding site
  • Loading branch information
cyberbuff authored Aug 28, 2024
2 parents a6182ce + 1be54c1 commit 73323b3
Show file tree
Hide file tree
Showing 535 changed files with 11,966 additions and 25,484 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy site

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

on:
push:
branches:
- main

jobs:
deploy-site:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python 3.12
uses: actions/[email protected]
with:
python-version: 3.12
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python -
- name: Install dependencies with Poetry
run: poetry install
- name: Generate MDX
run: poetry run python bin/site.py -v
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Deploy Project Artifacts to Vercel
run: |
cd website
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.vercel
website/pages/tools
156 changes: 33 additions & 123 deletions bin/jinja2_templates/rmm.md.j2
Original file line number Diff line number Diff line change
@@ -1,83 +1,40 @@
+++
---
description = "{{ rmm.Description | clean_multiline }}"
title = "{{ rmm.Name }}"
weight = 10
displayTitle = "{{ rmm.Name }}"
+++
---

{% raw %}
{{< block "grid-1" >}}
{{< column "mt-2 pt-1">}}
{% endraw %}

# {{ rmm.Name }}

{% if rmm.Category %}
**Category**: {{ rmm.Category }}
{% endif %}
import {Card, Badges, Details, PEMetadata, DiskArtifacts, EventLogTable, RegistryTable, OtherArtifactsTable, NetworkArtifactsTable} from "../../components/card";
import {EuiSpacer} from "@elastic/eui"

### Description
# {{ rmm.Name }}

{{ rmm.Description }}

{% if rmm.Author %}
**Author**: {{ rmm.Author }}
{% endif %}

{% if rmm.Created %}
**Created**: {{ rmm.Created }}
{% endif %}

{% if rmm.LastModified %}
**Last Modified**: {{ rmm.LastModified }}
{% endif %}

{% if rmm.Details %}
### Details
<Details author={"{{rmm.Author}}"}
category={"{{rmm.Category}}"}
created={"{{rmm.Created}}"}
website={"{{rmm.Details.Website}}"}
lastModified={"{{rmm.LastModified}}"}
privileges={"{{rmm.Details.Privileges}}"}
free={ {{dump(rmm.Details.Free)}} }
verification={"{{rmm.Details.Verification}}"}
/>

{% if rmm.Details.Website %}
- **Website**: [{{ rmm.Details.Website }}]({{ rmm.Details.Website }})
{% endif %}

{% if rmm.Details.PEMetadata %}
#### PE Metadata
{% if rmm.Details.PEMetadata is mapping %}
{% for key, value in rmm.Details.PEMetadata.items() %}
- **{{ key }}**: {{ value }}
{% endfor %}
{% else %}
{% for item in rmm.Details.PEMetadata %}
{% for key, value in item.items() %}
- **{{ key }}**: {{ value }}
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}

{% if rmm.Details.Privileges %}
- **Privileges**: {{ rmm.Details.Privileges }}
{% endif %}

{% if rmm.Details.Free is not none %}
- **Free**: {{ "Yes" if rmm.Details.Free else "No" }}
{% endif %}

{% if rmm.Details.Verification is not none %}
- **Verification**: {{ "Yes" if rmm.Details.Verification else "No" }}
{% if rmm.Details.InstallationPaths %}
#### Installation Paths
<Card code={ {{dump(rmm.Details.InstallationPaths)}} }/>
{% endif %}

{% if rmm.Details.SupportedOS %}
#### Supported Operating Systems
{% for os in rmm.Details.SupportedOS %}
- {{ os }}
{% endfor %}
#### Supported OS
<Badges color="warning" badges={ {{dump(rmm.Details.SupportedOS)}} }/>
{% endif %}

{% if rmm.Details.Capabilities %}
#### Capabilities
{% for capability in rmm.Details.Capabilities %}
- {{ capability }}
{% endfor %}
<Badges color="#FFA500" badges={ {{dump(rmm.Details.Capabilities)}} }/>
{% endif %}

{% if rmm.Details.Vulnerabilities %}
Expand All @@ -87,84 +44,41 @@ displayTitle = "{{ rmm.Name }}"
{% endfor %}
{% endif %}

{% if rmm.Details.InstallationPaths %}
#### Installation Paths
{% for path in rmm.Details.InstallationPaths %}
- `{{ path }}`
{% endfor %}
{% endif %}
{% endif %}

{% if rmm.Artifacts %}
### Forensic Artifacts

{% if rmm.Artifacts.Disk %}
#### Disk Artifacts
{% for artifact in rmm.Artifacts.Disk %}
- **File**: `{{ artifact.File }}`
{% if artifact.Description %}
**Description**: {{ artifact.Description }}
{% endif %}
{% if artifact.Example %}
**Example**:
```
{{ artifact.Example }}
```
{% endif %}
{% if artifact.OS %}
**OS**: {{ artifact.OS }}
{% endif %}
{% endfor %}
<EuiSpacer size="xl"/>
<DiskArtifacts data={ {{dump(rmm.Artifacts.Disk)}} }/>
{% endif %}

{% if rmm.Artifacts.EventLog %}
#### Event Log Artifacts
{% for artifact in rmm.Artifacts.EventLog %}
- Event Details:
{% for key, value in artifact.items() %}
- **{{ key }}**: {{ value }}
{% endfor %}
{% endfor %}
<EuiSpacer size="xl"/>
<EventLogTable data={ {{dump(rmm.Artifacts.EventLog)}} }/>
{% endif %}

{% if rmm.Artifacts.Registry %}
#### Registry Artifacts
{% for artifact in rmm.Artifacts.Registry %}
- **Path**: `{{ artifact.Path }}`
{% if artifact.Description %}
**Description**: {{ artifact.Description }}
{% endif %}
{% endfor %}
<EuiSpacer size="xl"/>
<RegistryTable data={ {{dump(rmm.Artifacts.Registry)}} }/>
{% endif %}

{% if rmm.Artifacts.Network %}
#### Network Artifacts
{% for artifact in rmm.Artifacts.Network %}
- {% if artifact.Description %}**Description**: {{ artifact.Description }}{% endif %}
{% if artifact.Domains %}
**Domains**:
{% for domain in artifact.Domains %}
- `{{ domain }}`
{% endfor %}
{% endif %}
{% if artifact.Ports %}
**Ports**:
{% for port in artifact.Ports %}
- `{{ port }}`
{% endfor %}
{% endif %}
{% endfor %}
<EuiSpacer size="xl"/>
<NetworkArtifactsTable data={ {{dump(rmm.Artifacts.Network)}} }/>
{% endif %}

{% if rmm.Artifacts.Other %}
#### Other Artifacts
{% for artifact in rmm.Artifacts.Other %}
- {% if artifact.Type %}**Type**: {{ artifact.Type }}{% endif %}
{% if artifact.Value %}
**Value**: {{ artifact.Value }}
{% endif %}
{% endfor %}
<EuiSpacer size="xl"/>
<OtherArtifactsTable data={ {{dump(rmm.Artifacts.Other)}} }/>
{% endif %}


{% endif %}

{% if rmm.Detections %}
Expand Down Expand Up @@ -197,10 +111,6 @@ displayTitle = "{{ rmm.Name }}"
### Acknowledgements
{% for ack in rmm.Acknowledgement %}
- {{ ack.Person }}{% if ack.Handle %} ({{ ack.Handle }}){% endif %}

{% endfor %}
{% endif %}

{% raw %}
{{< /column >}}
{{< /block >}}
{% endraw %}
33 changes: 18 additions & 15 deletions bin/site.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import datetime
import jinja2
import csv
import re

def write_rmm_tools_csv(rmm_tools, output_dir, VERBOSE):
output_file = os.path.join(output_dir, 'content', 'api', 'rmm_tools.csv')
output_file = os.path.join(output_dir, 'public', 'api', 'rmm_tools.csv')

header = ['Name', 'Category', 'Description', 'Author', 'Created', 'LastModified',
'Website', 'Filename', 'OriginalFileName', 'PEDescription', 'Product',
Expand Down Expand Up @@ -56,7 +57,7 @@ def write_rmm_tools_csv(rmm_tools, output_dir, VERBOSE):
writer.writerow(row)

def write_rmm_tools_table_csv(rmm_tools, output_dir, VERBOSE):
output_file = os.path.join(output_dir, 'content', 'rmm_tools_table.csv')
output_file = os.path.join(output_dir, 'public', 'rmm_tools_table.csv')

header = ['Name', 'Category', 'Description', 'Author']

Expand Down Expand Up @@ -112,37 +113,39 @@ def clean_multiline(text):
return text

j2_env.filters['clean_multiline'] = clean_multiline

j2_env.globals.update(dump=json.dumps)
j2_env.globals.update(escape=re.escape)

d = datetime.datetime.now()
template = j2_env.get_template('rmm.md.j2')
for rmm_tool in rmm_tools:
# Replace parentheses with underscores in the file name
file_name = f"{rmm_tool['Name'].lower().replace(' ', '_').replace('(', '_').replace(')', '_')}.md"
output_path = os.path.join(OUTPUT_DIR, 'content', 'rmm_tools', file_name)
file_name = f"{rmm_tool['Name'].lower().replace(' ', '_').replace('(', '_').replace(')', '_')}.mdx"
output_path = os.path.join(OUTPUT_DIR, 'pages', 'tools', file_name)
output = template.render(rmm=rmm_tool, time=str(d.strftime("%Y-%m-%d")))
with open(output_path, 'w', encoding="utf-8") as f:
f.write(output)
messages.append(f"site_gen.py wrote {len(rmm_tools)} RMM tools markdown to: {os.path.join(OUTPUT_DIR, 'content', 'rmm_tools')}")
messages.append(f"site_gen.py wrote {len(rmm_tools)} RMM tools markdown to: {os.path.join(OUTPUT_DIR, 'pages', 'tools')}")

# Write API CSV
write_rmm_tools_csv(rmm_tools, OUTPUT_DIR, VERBOSE)
messages.append(f"site_gen.py wrote RMM tools CSV to: {os.path.join(OUTPUT_DIR, 'content', 'api', 'rmm_tools.csv')}")
messages.append(f"site_gen.py wrote RMM tools CSV to: {os.path.join(OUTPUT_DIR, 'public', 'api', 'rmm_tools.csv')}")

# Write API JSON
with open(os.path.join(OUTPUT_DIR, 'content', 'api', 'rmm_tools.json'), 'w', encoding='utf-8') as f:
with open(os.path.join(OUTPUT_DIR, 'public', 'api', 'rmm_tools.json'), 'w', encoding='utf-8') as f:
json.dump(rmm_tools, f, ensure_ascii=False, indent=4)
messages.append(f"site_gen.py wrote RMM tools JSON to: {os.path.join(OUTPUT_DIR, 'content', 'api', 'rmm_tools.json')}")
messages.append(f"site_gen.py wrote RMM tools JSON to: {os.path.join(OUTPUT_DIR, 'public', 'api', 'rmm_tools.json')}")

# Write RMM tools table CSV
write_rmm_tools_table_csv(rmm_tools, OUTPUT_DIR, VERBOSE)
messages.append(f"site_gen.py wrote RMM tools table CSV to: {os.path.join(OUTPUT_DIR, 'content', 'rmm_tools_table.csv')}")
messages.append(f"site_gen.py wrote RMM tools table CSV to: {os.path.join(OUTPUT_DIR, 'public' , 'rmm_tools_table.csv')}")

return rmm_tools, messages

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generates LOLRMM site", epilog="This tool converts all LOLRMM YAMLs and builds the site with all the supporting components.")
parser.add_argument("-p", "--path", required=False, default="yaml", help="path to LOLRMM yaml folder. Defaults to `yaml`")
parser.add_argument("-o", "--output", required=False, default="lolrmm.com", help="path to the output directory for the site, defaults to `lolrmm.io`")
parser.add_argument("-o", "--output", required=False, default="website", help="path to the output directory for the site, defaults to `lolrmm.io`")
parser.add_argument("-v", "--verbose", required=False, default=False, action='store_true', help="prints verbose output")

args = parser.parse_args()
Expand All @@ -153,11 +156,11 @@ def clean_multiline(text):
TEMPLATE_PATH = os.path.join(os.path.dirname(__file__), 'jinja2_templates')

if VERBOSE:
print(f"Wiping the {os.path.join(OUTPUT_DIR, 'content', 'rmm_tools')} folder")
print(f"Wiping the {os.path.join(OUTPUT_DIR, 'pages', 'tools')} folder")

# Clean up old RMM tool files
try:
rmm_tools_dir = os.path.join(OUTPUT_DIR, 'content', 'rmm_tools')
rmm_tools_dir = os.path.join(OUTPUT_DIR, 'pages', 'tools')
for file in os.listdir(rmm_tools_dir):
if file.endswith(".md") and file != '_index.md':
os.remove(os.path.join(rmm_tools_dir, file))
Expand All @@ -166,8 +169,8 @@ def clean_multiline(text):
sys.exit(1)

# Clean up API artifacts
api_json = os.path.join(OUTPUT_DIR, 'content', 'api', 'rmm_tools.json')
api_csv = os.path.join(OUTPUT_DIR, 'content', 'api', 'rmm_tools.csv')
api_json = os.path.join(OUTPUT_DIR, 'public', 'api', 'rmm_tools.json')
api_csv = os.path.join(OUTPUT_DIR, 'public', 'api', 'rmm_tools.csv')
if os.path.exists(api_json):
os.remove(api_json)
if os.path.exists(api_csv):
Expand Down
3 changes: 0 additions & 3 deletions lolrmm.com/.gitignore

This file was deleted.

Empty file removed lolrmm.com/.hugo_build.lock
Empty file.
Loading

0 comments on commit 73323b3

Please sign in to comment.