Skip to content

Commit

Permalink
Merge pull request #789 from openziti/codeql-problems
Browse files Browse the repository at this point in the history
update to latest deps, updates to dev scripts
  • Loading branch information
dovholuknf authored Jan 29, 2025
2 parents 9c0d028 + b24eef7 commit 31dafc3
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,4 @@ tosign.exe
[0-9]*.[0-9]*.[0-9]*.json

.env*.ps1*
zac
2 changes: 1 addition & 1 deletion Installer/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $ADV_INST_HOME = "C:\Program Files (x86)\Caphyon\Advanced Installer ${ADV_INST_V
$SIGNTOOL="${ADV_INST_HOME}\third-party\winsdk\x64\signtool.exe"
$ADVINST = "${ADV_INST_HOME}\bin\x86\AdvancedInstaller.com"
$ADVPROJECT = "${scriptPath}\ZitiDesktopEdge.aip"
$ZITI_EDGE_TUNNEL_VERSION="v1.3.9"
$ZITI_EDGE_TUNNEL_VERSION="v1.4.2"

echo "Cleaning previous build folder if it exists"
Remove-Item "${buildPath}" -r -ErrorAction Ignore
Expand Down
1 change: 1 addition & 0 deletions ZitiUpdateService/ZitiUpdateService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
</Compile>
<Compile Include="checkers\UpdateCheckers.cs" />
<Compile Include="utils\MiniDump.cs" />
<Compile Include="utils\MinidumpMonitor.cs" />
<Compile Include="utils\Settings.cs" />
<Compile Include="UpdateService.cs">
<SubType>Component</SubType>
Expand Down
80 changes: 80 additions & 0 deletions ZitiUpdateService/utils/MinidumpMonitor.cs
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.");
}
}
}
}
3 changes: 3 additions & 0 deletions build-test-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ if (-not $version) {
Write-Host -ForegroundColor Green "$version"
}

Set-Content -Path "version" -Value $version -NoNewline
Write-Host "Updating version file to version: $version" -ForegroundColor Yellow

$outputPath = "$scriptDirectory\release-streams\${version}.json"
& .\Installer\output-build-json.ps1 -version $version -url $url -stream $stream -published_at $published_at -outputPath $outputPath

Expand Down
113 changes: 113 additions & 0 deletions fetch-zac.ps1
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"
}
10 changes: 5 additions & 5 deletions release-streams/beta.json
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"
}
]
}
2 changes: 1 addition & 1 deletion setup-ids-for-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function makeTestService {
[string]$ordinal,
[string[]]$attrs = @(),
[string]$binder = "@${user}.svc.${ordinal}.ziti",
[string]$dialer = "@${user}.svc.${ordinal}.ziti"
[string]$dialer = "@${user}"
)
$svc = "${user}.svc.${ordinal}.ziti"
Write-host "Creating test service: ${svc} for user: ${user}"
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.2.8
2.5.3.0

0 comments on commit 31dafc3

Please sign in to comment.