Skip to content

Commit 3b5e9db

Browse files
authored
Merge pull request #600 from AutomationSolutionz/fix-av-issues
Fix issues related to Antivirus systems falsely flagging ZeuZ Node as a malware/trojan/etc
2 parents c346edf + 0ee8e07 commit 3b5e9db

File tree

17 files changed

+215
-951
lines changed

17 files changed

+215
-951
lines changed

.github/workflows/node_runner.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ name: Go
22

33
on:
44
push:
5-
# branches: [ dev ]
6-
branches: [ '*' ]
7-
pull_request:
85
branches: [ '*' ]
6+
tags: [ 'v*' ]
97

108
jobs:
119

@@ -19,6 +17,9 @@ jobs:
1917
with:
2018
go-version: 1.23
2119

20+
- name: Install MinGW-w64
21+
run: sudo apt-get update && sudo apt-get install -y mingw-w64
22+
2223
- name: Build
2324
working-directory: ./Apps/node_runner
2425
run: make all
@@ -28,3 +29,10 @@ jobs:
2829
with:
2930
name: binaries
3031
path: ./Apps/node_runner/build/*
32+
33+
- name: Create Release
34+
if: startsWith(github.ref, 'refs/tags/v')
35+
uses: softprops/action-gh-release@v1
36+
with:
37+
files: ./Apps/node_runner/build/*
38+
generate_release_notes: true

Apps/node_runner/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all clean windows mac linux
1+
.PHONY: all clean windows mac linux checksums
22

33
# Output directory
44
BUILD_DIR=build
@@ -8,8 +8,10 @@ VERSION=1.0.0
88
APPNAME=ZeuZ_Node
99

1010
windows:
11+
x86_64-w64-mingw32-windres -o resource.syso resource.rc
1112
GOOS=windows GOARCH=amd64 go build -o '$(BUILD_DIR)/$(APPNAME).exe' main.go
1213
GOOS=windows GOARCH=arm64 go build -o '$(BUILD_DIR)/$(APPNAME)_arm64.exe' main.go
14+
rm -f resource.syso
1315

1416
mac:
1517
GOOS=darwin GOARCH=arm64 go build -o '$(BUILD_DIR)/$(APPNAME)_macos' main.go
@@ -19,7 +21,10 @@ linux:
1921
GOOS=linux GOARCH=amd64 go build -o '$(BUILD_DIR)/$(APPNAME)_linux' main.go
2022
GOOS=linux GOARCH=arm64 go build -o '$(BUILD_DIR)/$(APPNAME)_linux_arm64' main.go
2123

22-
all: windows linux mac
24+
checksums:
25+
cd $(BUILD_DIR) && sha256sum * > checksums.txt
26+
27+
all: windows linux mac checksums
2328

2429
clean:
2530
rm -rf $(BUILD_DIR)

Apps/node_runner/main.go

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"path/filepath"
1111
"runtime"
1212
"strings"
13+
14+
"github.com/automationsolutionz/Zeuz_Python_Node/Apps/node_runner/uv_installer"
1315
)
1416

1517
const (
@@ -172,43 +174,29 @@ func installUV() error {
172174

173175
fmt.Println("Installing UV...")
174176

175-
// Create temporary directory for installation files
176-
tempDir, err := os.MkdirTemp("", "uv-install")
177-
if err != nil {
178-
return fmt.Errorf("failed to create temp directory: %v", err)
179-
}
180-
defer os.RemoveAll(tempDir)
181-
182-
var (
183-
scriptURL string
184-
scriptPath string
185-
cmd *exec.Cmd
186-
)
187-
188177
if runtime.GOOS == "windows" {
189-
scriptURL = "https://astral.sh/uv/install.ps1"
190-
scriptPath = filepath.Join(tempDir, "install.ps1")
191-
192-
if err := downloadFile(scriptURL, scriptPath); err != nil {
193-
return err
178+
return uv_installer.InstallUVFromSource()
179+
} else {
180+
// For non-Windows systems, use the shell script
181+
tempDir, err := os.MkdirTemp("", "uv-install")
182+
if err != nil {
183+
return fmt.Errorf("failed to create temp directory: %v", err)
194184
}
185+
defer os.RemoveAll(tempDir)
195186

196-
cmd = exec.Command("powershell", "-ExecutionPolicy", "ByPass", "-File", scriptPath)
197-
} else {
198-
scriptURL = "https://astral.sh/uv/install.sh"
199-
scriptPath = filepath.Join(tempDir, "install.sh")
187+
scriptURL := "https://astral.sh/uv/install.sh"
188+
scriptPath := filepath.Join(tempDir, "install.sh")
200189

201190
if err := downloadFile(scriptURL, scriptPath); err != nil {
202191
return err
203192
}
204193

205-
cmd = exec.Command("sh", scriptPath)
194+
cmd := exec.Command("sh", scriptPath)
195+
cmd.Stdout = os.Stdout
196+
cmd.Stderr = os.Stderr
197+
cmd.Stdin = os.Stdin
198+
return cmd.Run()
206199
}
207-
208-
cmd.Stdout = os.Stdout
209-
cmd.Stderr = os.Stderr
210-
cmd.Stdin = os.Stdin
211-
return cmd.Run()
212200
}
213201

214202
// updatePath adds UV binary location to PATH

Apps/node_runner/resource.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IDI_ICON1 ICON "icon.ico"
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
package uv_installer
2+
3+
import (
4+
"archive/zip"
5+
"encoding/json"
6+
"fmt"
7+
"io"
8+
"net/http"
9+
"os"
10+
"path/filepath"
11+
"runtime"
12+
"strings"
13+
)
14+
15+
type GitHubRelease struct {
16+
TagName string `json:"tag_name"`
17+
Assets []struct {
18+
Name string `json:"name"`
19+
BrowserDownloadURL string `json:"browser_download_url"`
20+
} `json:"assets"`
21+
}
22+
23+
// getLatestUVRelease fetches the latest uv release info from GitHub
24+
func getLatestUVRelease() (*GitHubRelease, error) {
25+
resp, err := http.Get("https://api.github.com/repos/astral-sh/uv/releases/latest")
26+
if err != nil {
27+
return nil, fmt.Errorf("failed to fetch release info: %v", err)
28+
}
29+
defer resp.Body.Close()
30+
31+
var release GitHubRelease
32+
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
33+
return nil, fmt.Errorf("failed to parse release info: %v", err)
34+
}
35+
36+
return &release, nil
37+
}
38+
39+
// getUVArchitecture returns the appropriate uv architecture string
40+
func getUVArchitecture() string {
41+
switch runtime.GOARCH {
42+
case "amd64":
43+
return "x86_64-pc-windows-msvc"
44+
case "386":
45+
return "i686-pc-windows-msvc"
46+
case "arm64":
47+
return "aarch64-pc-windows-msvc"
48+
default:
49+
return "x86_64-pc-windows-msvc"
50+
}
51+
}
52+
53+
// downloadUV downloads the uv binary for the current platform
54+
func downloadUV(release *GitHubRelease) (string, error) {
55+
arch := getUVArchitecture()
56+
assetName := fmt.Sprintf("uv-%s.zip", arch)
57+
58+
var downloadURL string
59+
for _, asset := range release.Assets {
60+
if asset.Name == assetName {
61+
downloadURL = asset.BrowserDownloadURL
62+
break
63+
}
64+
}
65+
66+
if downloadURL == "" {
67+
return "", fmt.Errorf("could not find asset for architecture: %s", arch)
68+
}
69+
70+
tempDir, err := os.MkdirTemp("", "uv-download")
71+
if err != nil {
72+
return "", fmt.Errorf("failed to create temp directory: %v", err)
73+
}
74+
75+
zipPath := filepath.Join(tempDir, "uv.zip")
76+
resp, err := http.Get(downloadURL)
77+
if err != nil {
78+
return "", fmt.Errorf("failed to download uv: %v", err)
79+
}
80+
defer resp.Body.Close()
81+
82+
out, err := os.Create(zipPath)
83+
if err != nil {
84+
return "", fmt.Errorf("failed to create zip file: %v", err)
85+
}
86+
defer out.Close()
87+
88+
_, err = io.Copy(out, resp.Body)
89+
if err != nil {
90+
return "", fmt.Errorf("failed to write zip file: %v", err)
91+
}
92+
93+
return zipPath, nil
94+
}
95+
96+
// extractUV extracts uv binaries from the zip file
97+
func extractUV(zipPath, destDir string) error {
98+
reader, err := zip.OpenReader(zipPath)
99+
if err != nil {
100+
return fmt.Errorf("failed to open zip file: %v", err)
101+
}
102+
defer reader.Close()
103+
104+
if err := os.MkdirAll(destDir, 0755); err != nil {
105+
return fmt.Errorf("failed to create destination directory: %v", err)
106+
}
107+
108+
for _, file := range reader.File {
109+
if file.FileInfo().IsDir() {
110+
continue
111+
}
112+
113+
// Only extract .exe files
114+
if !strings.HasSuffix(file.Name, ".exe") {
115+
continue
116+
}
117+
118+
fileName := filepath.Base(file.Name)
119+
destPath := filepath.Join(destDir, fileName)
120+
121+
rc, err := file.Open()
122+
if err != nil {
123+
return fmt.Errorf("failed to open file in zip: %v", err)
124+
}
125+
126+
outFile, err := os.Create(destPath)
127+
if err != nil {
128+
rc.Close()
129+
return fmt.Errorf("failed to create output file: %v", err)
130+
}
131+
132+
_, err = io.Copy(outFile, rc)
133+
rc.Close()
134+
outFile.Close()
135+
if err != nil {
136+
return fmt.Errorf("failed to copy file: %v", err)
137+
}
138+
}
139+
140+
return nil
141+
}
142+
143+
// getUVInstallDir returns the installation directory for uv
144+
func getUVInstallDir() (string, error) {
145+
home, err := os.UserHomeDir()
146+
if err != nil {
147+
return "", fmt.Errorf("failed to get home directory: %v", err)
148+
}
149+
150+
return filepath.Join(home, ".local", "bin"), nil
151+
}
152+
153+
// InstallUVFromSource downloads and installs the latest uv release
154+
func InstallUVFromSource() error {
155+
fmt.Println("Fetching latest uv release...")
156+
release, err := getLatestUVRelease()
157+
if err != nil {
158+
return err
159+
}
160+
161+
fmt.Printf("Downloading uv %s...\n", release.TagName)
162+
zipPath, err := downloadUV(release)
163+
if err != nil {
164+
return err
165+
}
166+
defer os.RemoveAll(filepath.Dir(zipPath))
167+
168+
installDir, err := getUVInstallDir()
169+
if err != nil {
170+
return err
171+
}
172+
173+
fmt.Printf("Installing to %s...\n", installDir)
174+
if err := extractUV(zipPath, installDir); err != nil {
175+
return err
176+
}
177+
178+
fmt.Printf("Successfully installed uv %s\n", release.TagName)
179+
return nil
180+
}

Apps/zeuz-cli/Zeuz CLI guide.pdf

-162 KB
Binary file not shown.

0 commit comments

Comments
 (0)