Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Kibana Reports to be easily accessed, don't delete, and set 1.0… #5

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ProcessedHashes.txt
Nessus_Exports/*
all_results.json
ingest_errors.json
Kibana_Reports/*
17 changes: 12 additions & 5 deletions Invoke-Power-Nessie.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Begin{
$option7 = "7. Export PDF or CSV Report from Kibana dashboard and optionally send via Email (Advanced Options - Copy POST URL)."
#$option10 = "10. Delete oldest scan from scan history (Future / Only works with Nessus Manager license)"
$quit = "Q. Quit"
$version = "`nVersion 0.11.0"
$version = "`nVersion 1.0.0"

function Show-Menu {
Write-Host "Welcome to the PowerShell script that can export and ingest Nessus scan files into an Elastic stack!" -ForegroundColor Blue
Expand Down Expand Up @@ -1768,6 +1768,13 @@ Begin{
Write-Host "No Export URL for PDF or CSV provided, exiting" -ForegroundColor Yellow
exit
}

# Check to see if report export directory exists, if not, create it!
if ($(Test-Path -Path "Kibana_Reports") -eq $false) {
Write-Host "Could not find Kibana Reports so creating that directory now."
New-Item "Kibana_Reports" -ItemType Directory
}

$kibanaHeader = @{"kbn-xsrf" = "true"; "Authorization" = "ApiKey $Elasticsearch_Api_Key"}

$result = Invoke-RestMethod -Method POST -Uri $Kibana_Export_URL -Headers $kibanaHeader -ContentType "application/json" -SkipCertificateCheck -MaximumRetryCount 10 -ConnectionTimeoutSeconds 120
Expand All @@ -1776,7 +1783,7 @@ Begin{
$result.errors
}else{
# Create a temporary file name for downloading the report
$tempFile = [System.IO.Path]::GetTempFileName()
$tempFile = $(Join-Path "Kibana_Reports" $(New-Guid).Guid)+".tmp"
# Extract Kibana URL from Export URL
$Kibana_Export_URL -match "^.*(?=/api/reporting/generate)" | Out-Null
# Check for Kibana URL match
Expand Down Expand Up @@ -2210,9 +2217,9 @@ Process {
}

# Clean up files after generation
$reportedItemFiles | ForEach-Object {
Remove-Item $_
}
# $reportedItemFiles | ForEach-Object {
# Remove-Item $_
#}

$finished = $true
break
Expand Down