-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #789 from openziti/codeql-problems
update to latest deps, updates to dev scripts
- Loading branch information
Showing
9 changed files
with
206 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,3 +288,4 @@ tosign.exe | |
[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
.env*.ps1* | ||
zac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
|
||
namespace ZitiUpdateService { | ||
public class MinidumpMonitor { | ||
[Flags] | ||
private enum MiniDumpType { | ||
MiniDumpNormal = 0x00000000, | ||
MiniDumpWithDataSegs = 0x00000001, | ||
MiniDumpWithFullMemory = 0x00000002, | ||
MiniDumpWithHandleData = 0x00000004, | ||
MiniDumpFilterMemory = 0x00000008, | ||
MiniDumpScanMemory = 0x00000010, | ||
MiniDumpWithUnloadedModules = 0x00000020, | ||
MiniDumpWithIndirectlyReferencedMemory = 0x00000040, | ||
MiniDumpFilterModulePaths = 0x00000080, | ||
MiniDumpWithProcessThreadData = 0x00000100, | ||
MiniDumpWithPrivateReadWriteMemory = 0x00000200, | ||
MiniDumpWithoutOptionalData = 0x00000400, | ||
MiniDumpWithFullMemoryInfo = 0x00000800, | ||
MiniDumpWithThreadInfo = 0x00001000, | ||
MiniDumpWithCodeSegs = 0x00002000 | ||
} | ||
|
||
[DllImport("DbgHelp.dll")] | ||
private static extern bool MiniDumpWriteDump( | ||
IntPtr hProcess, | ||
int processId, | ||
SafeHandle hFile, | ||
MiniDumpType dumpType, | ||
IntPtr exceptionParam, | ||
IntPtr userStreamParam, | ||
IntPtr callbackParam); | ||
|
||
private readonly string _processName; | ||
|
||
public MinidumpMonitor(string processName) { | ||
_processName = processName; | ||
} | ||
|
||
public void StartMonitoring() { | ||
var targetProcess = Process.GetProcessesByName(_processName); | ||
if (targetProcess.Length == 0) { | ||
Console.WriteLine($"Target process '{_processName}' not found."); | ||
return; | ||
} | ||
|
||
var process = targetProcess[0]; | ||
process.EnableRaisingEvents = true; | ||
process.Exited += (sender, e) => { | ||
Console.WriteLine($"Process {_processName} has exited. Capturing minidump..."); | ||
|
||
string dumpPath = Path.Combine(Environment.CurrentDirectory, $"{_processName}.dmp"); | ||
CaptureMinidump(process, dumpPath); | ||
}; | ||
|
||
Console.WriteLine($"Monitoring process {_processName}..."); | ||
} | ||
|
||
private void CaptureMinidump(Process process, string dumpPath) { | ||
using (FileStream fs = new FileStream(dumpPath, FileMode.Create, FileAccess.Write, FileShare.None)) { | ||
bool success = MiniDumpWriteDump( | ||
process.Handle, | ||
process.Id, | ||
fs.SafeFileHandle, | ||
MiniDumpType.MiniDumpWithFullMemory, | ||
IntPtr.Zero, | ||
IntPtr.Zero, | ||
IntPtr.Zero); | ||
|
||
Console.WriteLine(success | ||
? $"Minidump written to {dumpPath}" | ||
: "Failed to write minidump."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Parameters | ||
param ( | ||
[string]$repo = "openziti/ziti-console", # Replace with the target GitHub repository | ||
[string]$version # Version number in #.#.# format, or "latest" for the newest release | ||
) | ||
|
||
# Variables | ||
$apiUrl = "https://api.github.com/repos/$repo/releases" | ||
$zacDir = $zacDir = Join-Path -Path (Get-Location) -ChildPath "zac" | ||
|
||
# Function to download artifact | ||
function Download-Artifact { | ||
param ( | ||
[string]$tag, | ||
[string]$artifactName | ||
) | ||
|
||
$url = "https://github.com/$repo/releases/download/$tag/$artifactName" | ||
$outputPath = Join-Path -Path $zacDir -ChildPath "$tag.zip" | ||
|
||
if (-not (Test-Path $zacDir)) { | ||
New-Item -ItemType Directory -Path $zacDir | Out-Null | ||
} | ||
|
||
Write-Host "Downloading artifact from: $url" | ||
$ProgressPreference = 'SilentlyContinue' | ||
Invoke-WebRequest -Uri $url -OutFile $outputPath | ||
Write-Host "Artifact saved to: $outputPath" | ||
return $outputPath | ||
} | ||
|
||
# Function to unzip artifact | ||
function Unzip-Artifact { | ||
param ( | ||
[string]$zipPath, | ||
[string]$extractTo | ||
) | ||
|
||
if (-not (Test-Path $zipPath)) { | ||
Write-Host "Zip file not found: $zipPath" | ||
exit 1 | ||
} | ||
|
||
if (-not (Test-Path $extractTo)) { | ||
New-Item -ItemType Directory -Path $extractTo | Out-Null | ||
} | ||
|
||
Write-Host "Extracting $zipPath to $extractTo" | ||
$global:ProgressPreference = "SilentlyContinue" | ||
Expand-Archive -Path $zipPath -DestinationPath $extractTo -Force | Out-Null | ||
Write-Host "Extraction complete." | ||
} | ||
|
||
# Fetch releases | ||
try { | ||
$releases = Invoke-RestMethod -Uri $apiUrl -Headers @{ "User-Agent" = "PowerShell" } | ||
} catch { | ||
Write-Host "Error fetching releases: $_" | ||
exit 1 | ||
} | ||
|
||
if (-not $version -or $version -eq 'latest') { | ||
# Find the latest release that matches "app-ziti-console-" | ||
$latestRelease = $releases | Where-Object { $_.tag_name -match "app-ziti-console-" } | Select-Object -First 1 | ||
if ($latestRelease) { | ||
Write-Host "Latest release found:" | ||
Write-Host "Name: $($latestRelease.name)" | ||
Write-Host "Tag: $($latestRelease.tag_name)" | ||
Write-Host "URL: $($latestRelease.html_url)" | ||
|
||
$artifactPath = (Download-Artifact -tag $latestRelease.tag_name -artifactName "ziti-console.zip") | ||
echo "Artfiact downloaded to : $artifactPath" | ||
$where = (Join-Path -Path $zacDir -ChildPath $latestRelease.tag_name.Replace("app-", "")) | ||
Unzip-Artifact -zipPath $artifactPath -extractTo $where | ||
|
||
Write-Host " - binding: zac" | ||
Write-Host " options:" | ||
Write-Host " location: ""$where""" | ||
Write-Host " indexFile: index.html" | ||
} else { | ||
Write-Host "No releases matching 'app-ziti-console-' found." | ||
} | ||
exit 0 | ||
} | ||
|
||
# Validate version input | ||
if (-not ($version -match '^(\\d+)\\.(\\d+)\\.(\\d+)$')) { | ||
Write-Host "Invalid version format. Use #.#.# (e.g., 3.7.0)." | ||
exit 1 | ||
} | ||
|
||
# Find matching release | ||
$pattern = "app-ziti-console-v$version" | ||
$matchingRelease = $releases | Where-Object { $_.tag_name -match $pattern } | ||
|
||
if ($matchingRelease) { | ||
Write-Host "Matching release found:" | ||
Write-Host "Name: $($matchingRelease.name)" | ||
Write-Host "Tag: $($matchingRelease.tag_name)" | ||
Write-Host "URL: $($matchingRelease.html_url)" | ||
|
||
$artifactPath = Download-Artifact -tag $matchingRelease.tag_name -artifactName "ziti-console.zip" | ||
$where = (Join-Path -Path $zacDir -ChildPath $matchingRelease.tag_name.Replace("app-", "")) | ||
Unzip-Artifact -zipPath $artifactPath -extractTo $where | ||
|
||
Write-Host " - binding: zac" | ||
Write-Host " options:" | ||
Write-Host " location: ""$where""" | ||
Write-Host " indexFile: index.html" | ||
|
||
} else { | ||
Write-Host "No matching release found for pattern: $pattern" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"name": "2.5.2.8", | ||
"tag_name": "2.5.2.8", | ||
"published_at": "2025-01-16T09:33:17Z", | ||
"name": "2.5.3.0", | ||
"tag_name": "2.5.3.0", | ||
"published_at": "2025-01-29T02:16:10Z", | ||
"installation_critical": false, | ||
"assets": [ | ||
{ | ||
"name": "Ziti.Desktop.Edge.Client-2.5.2.8.exe", | ||
"browser_download_url": "https://github.com/openziti/desktop-edge-win/releases/download/2.5.2.8/Ziti.Desktop.Edge.Client-2.5.2.8.exe" | ||
"name": "Ziti.Desktop.Edge.Client-2.5.3.0.exe", | ||
"browser_download_url": "https://github.com/openziti/desktop-edge-win/releases/download/2.5.3.0/Ziti.Desktop.Edge.Client-2.5.3.0.exe" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.5.2.8 | ||
2.5.3.0 |