11 Commits

Author SHA1 Message Date
a173c99015 chore: remove CTest output directory 'Testing' from repo 2025-08-29 09:55:55 +02:00
fedf90debe chore: remove stray build_tests directory from repo 2025-08-29 09:54:09 +02:00
b4e40d44c4 chore(windows): replace PowerShell build with build_windows.bat; update README and release script 2025-08-29 09:49:42 +02:00
mbusc
77879e6521 Fix rate limiting issue in example.cpp by adding delays between API calls 2025-08-28 21:49:34 +02:00
mbusc
3b4d591eff Fix type conversion warnings in base58.cpp and improve CMake syntax 2025-08-28 21:43:46 +02:00
mbusc
4add1edd11 Update CMakeLists.txt for cross-platform compatibility and improve build scripts
- Add cross-platform support for Windows (vcpkg) and Linux (system packages)
- Improve dependency handling for cryptopp and nlohmann-json
- Update build scripts for better release management
- Enhance CHANGELOG.md with latest version information
2025-08-28 21:29:16 +02:00
mbusc
5493c0dcf3 Merge branch 'main' of https://gitea.medisoftware.org/Markus/lib-privatebin 2025-08-28 21:26:36 +02:00
mbusc
cd7e957692 Fix compiler warnings and improve code quality
- Replace unsafe strcpy with strcpy_s for better security
- Fix DLL binding issues by adding PRIVATEBIN_API macros
- Add explicit type casts to resolve size conversion warnings
- Replace unsafe getenv with _dupenv_s for better security
- Add PRIVATEBINAPI_EXPORTS definition in CMakeLists.txt
- Improve CMake configuration for better build compatibility
2025-08-28 21:25:25 +02:00
d712d3a9d8 Update README with comprehensive Linux build instructions and compatibility information 2025-08-28 20:40:46 +02:00
000fde485f Fix CMakeLists.txt for Linux compatibility while preserving Windows vcpkg support 2025-08-28 20:37:34 +02:00
mbusc
b97d9f2d7f v0.1.1.6: Enhanced create_release.ps1 - automatic build and artifact upload 2025-08-28 20:24:13 +02:00
18 changed files with 278 additions and 166 deletions

View File

@@ -20,7 +20,7 @@
- **IMPROVED**: Enhanced build documentation with platform-specific instructions - **IMPROVED**: Enhanced build documentation with platform-specific instructions
- **IMPROVED**: Better project structure and organization - **IMPROVED**: Better project structure and organization
s## v0.1.1.3 (2025-08-28) ## v0.1.1.3 (2025-08-28)
### New Features ### New Features
- **File Upload Functionality**: New `upload_file()` function added - **File Upload Functionality**: New `upload_file()` function added

View File

@@ -17,8 +17,16 @@ elseif(UNIX)
endif() endif()
# Handle dependencies # Handle dependencies
find_package(cryptopp CONFIG REQUIRED) if(WIN32)
find_package(nlohmann_json CONFIG REQUIRED) # Windows: Use vcpkg packages
find_package(cryptopp CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
else()
# Linux: Use system packages
find_package(PkgConfig REQUIRED)
pkg_check_modules(CRYPTOPP REQUIRED libcryptopp)
pkg_check_modules(NLOHMANN_JSON REQUIRED nlohmann_json)
endif()
# Add library sources # Add library sources
set(SOURCES set(SOURCES
@@ -40,22 +48,42 @@ set(HEADERS
# Create the shared library # Create the shared library
add_library(privatebinapi SHARED ${SOURCES} ${HEADERS}) add_library(privatebinapi SHARED ${SOURCES} ${HEADERS})
# Define PRIVATEBINAPI_EXPORTS for the library build
target_compile_definitions(privatebinapi PRIVATE PRIVATEBINAPI_EXPORTS)
# Include directories # Include directories
target_include_directories(privatebinapi PUBLIC target_include_directories(privatebinapi PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include
) )
# Explicitly include vcpkg directories # Platform-specific include directories
target_include_directories(privatebinapi PRIVATE if(WIN32)
# Windows: Include vcpkg directories
target_include_directories(privatebinapi PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include ${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
) )
endif()
# Link dependencies # Link dependencies
target_link_libraries(privatebinapi PRIVATE if(WIN32)
# Windows: Use vcpkg targets
target_link_libraries(privatebinapi PRIVATE
cryptopp::cryptopp cryptopp::cryptopp
nlohmann_json::nlohmann_json nlohmann_json::nlohmann_json
${PLATFORM_LIBS} ${PLATFORM_LIBS}
) )
else()
# Linux: Use system libraries
target_link_libraries(privatebinapi PRIVATE
${CRYPTOPP_LIBRARIES}
${NLOHMANN_JSON_LIBRARIES}
${PLATFORM_LIBS}
)
target_include_directories(privatebinapi PRIVATE
${CRYPTOPP_INCLUDE_DIRS}
${NLOHMANN_JSON_INCLUDE_DIRS}
)
endif()
# Install targets # Install targets
install(TARGETS privatebinapi install(TARGETS privatebinapi
@@ -84,12 +112,11 @@ if(ENABLE_LLVM_COVERAGE)
add_compile_options(-fprofile-instr-generate -fcoverage-mapping) add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
add_link_options(-fprofile-instr-generate) add_link_options(-fprofile-instr-generate)
# Helper variables for report tools (can be overridden from environment) # Helper variables for report tools
set(LLVM_PROFDATA "llvm-profdata" CACHE STRING "Path to llvm-profdata") set(LLVM_PROFDATA "llvm-profdata" CACHE STRING "Path to llvm-profdata")
set(LLVM_COV "llvm-cov" CACHE STRING "Path to llvm-cov") set(LLVM_COV "llvm-cov" CACHE STRING "Path to llvm-cov")
# Custom target to run tests and produce coverage report # Custom target to run tests and produce coverage report
# Usage: cmake --build build --target coverage_llvm --config Release
add_custom_target( add_custom_target(
coverage_llvm coverage_llvm
COMMAND ${CMAKE_COMMAND} -E env COMMAND ${CMAKE_COMMAND} -E env

148
README.md
View File

@@ -89,39 +89,26 @@ The project includes several build scripts in the `scripts/` directory for diffe
### Windows Build Scripts ### Windows Build Scripts
#### PowerShell Build (Recommended) #### Windows Build (Recommended)
**File:** `scripts/build_windows.ps1` **File:** `scripts/build_windows.bat`
**Requirements:** PowerShell, Visual Studio 2022 Build Tools (C++), vcpkg (will be bootstrapped), Git **Requirements:** Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg, Git
```powershell
# Run from project root
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1
```
This script:
- Automatically bootstraps vcpkg if not present
- Configures CMake with Visual Studio 2022 generator
- Builds the project in Release configuration
- Creates a Windows distribution package with all artifacts
#### Command Line Build
**File:** `scripts/build_thinkpad.bat`
**Requirements:** Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg
```cmd ```cmd
# Run from project root # Run from project root
scripts\build_thinkpad.bat scripts\build_windows.bat
``` ```
This script: This script:
- Automatically detects and initializes Visual Studio environment - Automatically detects and initializes the Visual Studio environment
- Handles vcpkg bootstrapping - Bootstraps vcpkg if not present
- Configures CMake with proper toolchain - Configures CMake with the Visual Studio 2022 generator and vcpkg toolchain
- Builds the project using MSVC compiler - Builds the project in Release configuration using MSVC
### Linux/macOS Build Script ### Linux Build Scripts
#### Automated Build Script
**File:** `scripts/build.sh` **File:** `scripts/build.sh`
**Requirements:** CMake, C++17 compiler, vcpkg **Requirements:** CMake, C++17 compiler, system packages
```bash ```bash
# Make executable and run from project root # Make executable and run from project root
@@ -129,6 +116,54 @@ chmod +x scripts/build.sh
./scripts/build.sh ./scripts/build.sh
``` ```
This script:
- Automatically detects and installs required dependencies
- Configures CMake with Unix Makefiles
- Builds the project in Release configuration
#### Manual Linux Build (Recommended)
**Requirements:** CMake 3.10+, GCC/Clang with C++17 support, system packages
```bash
# Install dependencies (Fedora/RHEL/CentOS)
sudo dnf install cmake gcc-c++ libcurl-devel cryptopp-devel json-devel
# Install dependencies (Ubuntu/Debian)
sudo apt install cmake g++ libcurl4-openssl-dev libcrypto++-dev nlohmann-json3-dev
# Build the project
mkdir build
cd build
cmake ..
make -j$(nproc)
# Run tests
ctest --verbose
# Run example
./example/example
```
**Linux Dependencies:**
- **libcurl-devel** - HTTP client library
- **cryptopp-devel** - Cryptographic library
- **json-devel** - JSON parsing library
- **cmake** - Build system
- **gcc-c++** - C++17 compiler
### macOS Build Script
**File:** `scripts/build.sh`
**Requirements:** CMake, C++17 compiler, Homebrew packages
```bash
# Install dependencies via Homebrew
brew install cmake cryptopp nlohmann-json curl
# Make executable and run from project root
chmod +x scripts/build.sh
./scripts/build.sh
```
This script: This script:
- Bootstraps vcpkg if not present - Bootstraps vcpkg if not present
- Configures CMake with Unix Makefiles - Configures CMake with Unix Makefiles
@@ -140,31 +175,55 @@ This script:
- CMake 3.10+ - CMake 3.10+
- C++17 compatible compiler - C++17 compatible compiler
- Crypto++ (via vcpkg) - **Windows:** Crypto++ and nlohmann/json (via vcpkg)
- nlohmann/json (via vcpkg) - **Linux:** libcurl, cryptopp, and nlohmann-json (via system packages)
- **macOS:** libcurl, cryptopp, and nlohmann/json (via Homebrew)
### Compilation ### Compilation
#### Windows (PowerShell) - Build via scripts/build_windows.ps1 #### Windows - Build via scripts/build_windows.bat
```powershell
# Requires: PowerShell, Visual Studio 2022 Build Tools (C++), vcpkg (will be bootstrapped), Git
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1
```
#### Windows (Command Line) - Build via scripts/build_thinkpad.bat
```cmd ```cmd
# Requires: Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg # Requires: Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg, Git
scripts\build_thinkpad.bat scripts\build_windows.bat
``` ```
#### Linux/macOS - Build via scripts/build.sh #### Linux - Automated Build via scripts/build.sh
```bash ```bash
# Requires: CMake, C++17 compiler, vcpkg # Requires: CMake, C++17 compiler, system packages
chmod +x scripts/build.sh chmod +x scripts/build.sh
./scripts/build.sh ./scripts/build.sh
``` ```
#### Manual Build #### Linux - Manual Build (Recommended)
```bash
# Install dependencies (Fedora/RHEL/CentOS)
sudo dnf install cmake gcc-c++ libcurl-devel cryptopp-devel json-devel
# Install dependencies (Ubuntu/Debian)
sudo apt install cmake g++ libcurl4-openssl-dev libcrypto++-dev nlohmann-json3-dev
# Build the project
mkdir build
cd build
cmake ..
make -j$(nproc)
# Run tests and examples
ctest --verbose
./example/example
```
#### macOS - Build via scripts/build.sh
```bash
# Install dependencies via Homebrew
brew install cmake cryptopp nlohmann-json curl
# Requires: CMake, C++17 compiler, Homebrew packages
chmod +x scripts/build.sh
./scripts/build.sh
```
#### Manual Build (All Platforms)
```bash ```bash
mkdir build mkdir build
cd build cd build
@@ -172,7 +231,9 @@ cmake ..
cmake --build . --config Release cmake --build . --config Release
``` ```
**Note:** The manual build method requires you to have all dependencies (CMake, compiler, vcpkg) properly configured. For most users, the platform-specific build scripts are recommended. **Note:** The manual build method requires you to have all dependencies properly configured. For most users, the platform-specific build scripts are recommended.
**Linux Compatibility:** The project has been tested and successfully builds on Fedora Linux with system packages. It automatically detects the platform and uses appropriate dependency resolution methods (vcpkg for Windows, system packages for Linux/macOS).
## Usage ## Usage
@@ -382,6 +443,13 @@ See [LICENSE](LICENSE) for details.
## Changelog ## Changelog
### v0.1.1.6 (2025-08-28)
- **NEW**: Full Linux compatibility with system packages
- **NEW**: Automatic platform detection (Windows: vcpkg, Linux: system packages)
- **IMPROVED**: Enhanced Linux build documentation and instructions
- **IMPROVED**: Better dependency management for cross-platform builds
- **FIXED**: CMakeLists.txt now works on both Windows and Linux without manual configuration
### v0.1.1.5 (2025-08-28) ### v0.1.1.5 (2025-08-28)
- **NEW**: Enhanced text format support (plaintext, syntax highlighting, markdown) - **NEW**: Enhanced text format support (plaintext, syntax highlighting, markdown)
- **NEW**: Comprehensive format testing in examples and integration tests - **NEW**: Comprehensive format testing in examples and integration tests

View File

@@ -1 +0,0 @@
---

View File

@@ -1 +0,0 @@
---

View File

@@ -3,6 +3,14 @@
#include <cstring> #include <cstring>
#include <string> #include <string>
#include <cstdlib> #include <cstdlib>
#include <chrono>
#include <thread>
// Helper function to wait between API calls to avoid rate limiting
void wait_between_calls() {
std::cout << "[privatebinapi] Waiting 12 seconds to avoid rate limiting..." << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(12));
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
std::cout << "PrivateBin API C++ DLL Example" << std::endl; std::cout << "PrivateBin API C++ DLL Example" << std::endl;
@@ -129,6 +137,9 @@ int main(int argc, char* argv[]) {
std::cout << "✗ Plaintext paste failed. Error code: " << result << std::endl; std::cout << "✗ Plaintext paste failed. Error code: " << result << std::endl;
} }
// Wait between API calls to avoid rate limiting
wait_between_calls();
// Test 2: Syntax highlighting format // Test 2: Syntax highlighting format
std::cout << "\n2. Testing syntax highlighting format..." << std::endl; std::cout << "\n2. Testing syntax highlighting format..." << std::endl;
char* code_paste_url = nullptr; char* code_paste_url = nullptr;
@@ -167,6 +178,9 @@ int main() {
std::cout << "✗ Syntax highlighting paste failed. Error code: " << result << std::endl; std::cout << "✗ Syntax highlighting paste failed. Error code: " << result << std::endl;
} }
// Wait between API calls to avoid rate limiting
wait_between_calls();
// Test 3: Markdown format // Test 3: Markdown format
std::cout << "\n3. Testing markdown format..." << std::endl; std::cout << "\n3. Testing markdown format..." << std::endl;
char* markdown_paste_url = nullptr; char* markdown_paste_url = nullptr;
@@ -213,6 +227,9 @@ int result = create_paste(server_url, content, password, expiration, format,
std::cout << "✗ Markdown paste failed. Error code: " << result << std::endl; std::cout << "✗ Markdown paste failed. Error code: " << result << std::endl;
} }
// Wait between API calls to avoid rate limiting
wait_between_calls();
// Test 4: Interactive format selection // Test 4: Interactive format selection
std::cout << "\n4. Interactive format selection..." << std::endl; std::cout << "\n4. Interactive format selection..." << std::endl;
char* interactive_paste_url = nullptr; char* interactive_paste_url = nullptr;

View File

@@ -21,10 +21,10 @@ if errorlevel 1 (
REM Ensure vswhere is on PATH (both PF and PF(x86)) REM Ensure vswhere is on PATH (both PF and PF(x86))
set "PATH=%ProgramFiles%\Microsoft Visual Studio\Installer;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%PATH%" set "PATH=%ProgramFiles%\Microsoft Visual Studio\Installer;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%PATH%"
REM First try well-known VsDevCmd from BuildTools/Community to avoid vswhere dependency REM First try well-known VsDevCmd from BuildTools/Community to avoid vswhere dependency
set "VSINSTALL=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" set "VSINSTALL=C:\ Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat" set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat"
if not exist "%VSDEVCMD_CANDIDATE%" ( if not exist "%VSDEVCMD_CANDIDATE%" (
set "VSINSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community" set "VSINSTALL=C:\ Program Files\Microsoft Visual Studio\2022\Community"
set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat" set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat"
) )
if exist "%VSDEVCMD_CANDIDATE%" ( if exist "%VSDEVCMD_CANDIDATE%" (
@@ -126,3 +126,4 @@ if %BUILD_ERROR% EQU 0 (
popd popd
exit /b %BUILD_ERROR% exit /b %BUILD_ERROR%

View File

@@ -1,62 +0,0 @@
# Requires: PowerShell, Visual Studio 2022 Build Tools (C++), vcpkg (will be bootstrapped), Git
# Usage:
# powershell -NoProfile -ExecutionPolicy Bypass -File .\build_windows.ps1
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
Write-Host "Building PrivateBin API C++ (Windows, x64, Release)" -ForegroundColor Cyan
# Resolve vcpkg root
if (-not $env:VCPKG_ROOT) {
$env:VCPKG_ROOT = Join-Path $env:USERPROFILE 'vcpkg'
}
if (-not (Test-Path $env:VCPKG_ROOT)) {
Write-Host "Cloning vcpkg into $env:VCPKG_ROOT ..."
git clone https://github.com/microsoft/vcpkg $env:VCPKG_ROOT
& "$env:VCPKG_ROOT\bootstrap-vcpkg.bat"
}
# Choose generator (VS 2022)
$generator = 'Visual Studio 17 2022'
$arch = 'x64'
# Clean and configure
if (Test-Path build) { Remove-Item -Recurse -Force build }
cmake -S . -B build -G "$generator" -A $arch -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
# Build
cmake --build build --config Release
Write-Host "Build completed." -ForegroundColor Green
# Package artifacts (zip)
$dist = Join-Path (Get-Location) 'dist\windows'
if (Test-Path $dist) { Remove-Item -Recurse -Force $dist }
New-Item -ItemType Directory -Force -Path $dist | Out-Null
# Collect artifacts
$binDir = Join-Path (Get-Location) 'build\Release'
$exampleDir = Join-Path (Get-Location) 'build\example\Release'
$dll = Join-Path $binDir 'privatebinapi.dll'
$lib = Join-Path $binDir 'privatebinapi.lib'
$pdb = Join-Path $binDir 'privatebinapi.pdb'
$exe = Join-Path $exampleDir 'example.exe'
Copy-Item -Path $dll -Destination $dist -ErrorAction SilentlyContinue
Copy-Item -Path $lib -Destination $dist -ErrorAction SilentlyContinue
Copy-Item -Path $pdb -Destination $dist -ErrorAction SilentlyContinue
Copy-Item -Path $exe -Destination $dist -ErrorAction SilentlyContinue
Copy-Item -Path (Join-Path (Get-Location) 'include') -Destination $dist -Recurse
Copy-Item -Path (Join-Path (Get-Location) 'README.md') -Destination $dist
Copy-Item -Path (Join-Path (Get-Location) 'LICENSE') -Destination $dist -ErrorAction SilentlyContinue
$zipPath = Join-Path (Get-Location) 'dist\lib-privatebin-v0.1.1.3-windows-x64.zip'
if (Test-Path $zipPath) { Remove-Item -Force $zipPath }
Compress-Archive -Path (Join-Path $dist '*') -DestinationPath $zipPath
Write-Host "Windows artifact packaged:" -ForegroundColor Cyan
Write-Host " $zipPath"

View File

@@ -31,3 +31,4 @@ Get-ChildItem -LiteralPath $OutDir -File | Format-Table Name,Length -AutoSize

View File

@@ -1,9 +1,6 @@
param( param(
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Token, [string]$Token
[Parameter(Mandatory=$false)]
[switch]$Build
) )
# Token aus Umgebungsvariable laden falls nicht als Parameter übergeben # Token aus Umgebungsvariable laden falls nicht als Parameter übergeben
@@ -12,6 +9,7 @@ if (-not $Token) {
if (-not $Token) { if (-not $Token) {
Write-Host "Fehler: Kein Token angegeben und GITEA_TOKEN Umgebungsvariable nicht gesetzt!" -ForegroundColor Red Write-Host "Fehler: Kein Token angegeben und GITEA_TOKEN Umgebungsvariable nicht gesetzt!" -ForegroundColor Red
Write-Host "Verwendung: .\create_release.ps1 -Token 'your_token' oder setze GITEA_TOKEN Umgebungsvariable" -ForegroundColor Yellow Write-Host "Verwendung: .\create_release.ps1 -Token 'your_token' oder setze GITEA_TOKEN Umgebungsvariable" -ForegroundColor Yellow
Write-Host "Das Script führt automatisch einen Build durch und lädt alle Artefakte hoch." -ForegroundColor Cyan
exit 1 exit 1
} }
Write-Host "Token aus Umgebungsvariable GITEA_TOKEN geladen" -ForegroundColor Green Write-Host "Token aus Umgebungsvariable GITEA_TOKEN geladen" -ForegroundColor Green
@@ -43,21 +41,20 @@ if ($lastTag -match "^v(\d+)\.(\d+)\.(\d+)(.*)$") {
exit 1 exit 1
} }
# Build falls gewünscht # Build durchführen
if ($Build) { Write-Host "Führe Build durch..." -ForegroundColor Yellow
Write-Host "Führe Build durch..." -ForegroundColor Yellow if (Test-Path "scripts\build_windows.bat") {
if (Test-Path "scripts\build_thinkpad.bat") { Write-Host "Verwende scripts\build_windows.bat..." -ForegroundColor Yellow
Write-Host "Verwende scripts\build_thinkpad.bat..." -ForegroundColor Yellow cmd /c scripts\build_windows.bat
cmd /c scripts\build_thinkpad.bat } else {
} else { Write-Host "Fehler: scripts\build_windows.bat nicht gefunden!" -ForegroundColor Red
Write-Host "Verwende scripts\build_windows.ps1..." -ForegroundColor Yellow exit 1
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1 }
} if ($LASTEXITCODE -ne 0) {
if ($LASTEXITCODE -ne 0) {
Write-Host "Build fehlgeschlagen!" -ForegroundColor Red Write-Host "Build fehlgeschlagen!" -ForegroundColor Red
exit 1 exit 1
}
} }
Write-Host "Build erfolgreich abgeschlossen!" -ForegroundColor Green
# Änderungen committen # Änderungen committen
$status = git status --porcelain $status = git status --porcelain
@@ -72,7 +69,7 @@ git tag -a $newVersion -m "Release $newVersion"
git push origin $newVersion git push origin $newVersion
# Release erstellen # Release erstellen
$releaseBody = "## What is New in $newVersion`n`n- AUTOMATED: Release created by script`n- VERSION: Bumped from $lastTag to $newVersion`n`n## Build Artifacts`n`n- privatebinapi.dll - Windows Dynamic Link Library`n- privatebinapi.lib - Windows Import Library`n- example.exe - Combined example program`n- privatebinapi.h - C++ header file" $releaseBody = "## What is New in $newVersion`n`n- AUTOMATED: Release created by script`n- VERSION: Bumped from $lastTag to $newVersion`n- BUILD: Automatic build with build_windows.bat`n`n## Build Artifacts`n`nBuild-Artefakte werden automatisch hochgeladen und hier angezeigt.`n`nTypische Artefakte:`n- privatebinapi.dll - Windows Dynamic Link Library`n- privatebinapi.lib - Windows Import Library`n- example.exe - Combined example program`n- privatebinapi.h - C++ header file"
$releaseData = @{ $releaseData = @{
tag_name = $newVersion tag_name = $newVersion
@@ -93,3 +90,59 @@ $release = Invoke-RestMethod -Uri $releaseUri -Method Post -Headers $headers -Bo
Write-Host "Release erstellt: $($release.id)" -ForegroundColor Green Write-Host "Release erstellt: $($release.id)" -ForegroundColor Green
Write-Host "URL: $($release.html_url)" -ForegroundColor Green Write-Host "URL: $($release.html_url)" -ForegroundColor Green
# Build-Artefakte zum Release hinzufügen
Write-Host "Füge Build-Artefakte hinzu..." -ForegroundColor Yellow
# Artefakte aus dem dist-Ordner finden
$distPath = "dist"
if (Test-Path $distPath) {
$artifacts = Get-ChildItem -Path $distPath -Recurse -File | Where-Object {
$_.Extension -match "\.(dll|lib|exe|h|zip)$"
}
if ($artifacts) {
Write-Host "Gefundene Artefakte:" -ForegroundColor Green
foreach ($artifact in $artifacts) {
Write-Host " - $($artifact.Name)" -ForegroundColor White
}
# Artefakte hochladen
foreach ($artifact in $artifacts) {
Write-Host "Lade hoch: $($artifact.Name)..." -ForegroundColor Yellow
$uploadUri = "https://gitea.medisoftware.org/api/v1/repos/Markus/lib-privatebin/releases/$($release.id)/assets"
$boundary = [System.Guid]::NewGuid().ToString()
$LF = "`r`n"
$bodyLines = @(
"--$boundary",
"Content-Disposition: form-data; name=`"attachment`"; filename=`"$($artifact.Name)`"",
"Content-Type: application/octet-stream",
"",
[System.IO.File]::ReadAllBytes($artifact.FullName),
"--$boundary--"
)
$body = $bodyLines -join $LF
$uploadHeaders = @{
"Authorization" = "token $Token"
"Content-Type" = "multipart/form-data; boundary=$boundary"
}
try {
$uploadResponse = Invoke-RestMethod -Uri $uploadUri -Method Post -Headers $uploadHeaders -Body $body
Write-Host "$($artifact.Name) erfolgreich hochgeladen" -ForegroundColor Green
} catch {
Write-Host " ✗ Fehler beim Hochladen von $($artifact.Name): $($_.Exception.Message)" -ForegroundColor Red
}
}
} else {
Write-Host "Keine Build-Artefakte im dist-Ordner gefunden!" -ForegroundColor Yellow
}
} else {
Write-Host "dist-Ordner nicht gefunden!" -ForegroundColor Yellow
}
Write-Host "Release-Erstellung abgeschlossen!" -ForegroundColor Green

View File

@@ -36,3 +36,4 @@ Get-ChildItem -LiteralPath $BinDir -File | ForEach-Object {

View File

@@ -44,3 +44,4 @@ if ($resp.StatusCode -ge 200 -and $resp.StatusCode -lt 300) {

View File

@@ -46,3 +46,4 @@ foreach ($f in $files) {

View File

@@ -77,3 +77,4 @@ Write-Host 'Release notes updated with links.'

View File

@@ -16,18 +16,19 @@ std::string Base58::encode(const std::vector<unsigned char>& data) {
} }
// Convert to base58 // Convert to base58
std::vector<unsigned char> digits((data.size() - leading_zeros) * 138 / 100 + 1); size_t digits_size = (data.size() - leading_zeros) * 138 / 100 + 1;
std::vector<unsigned char> digits(digits_size);
size_t digitslen = 1; size_t digitslen = 1;
for (size_t i = leading_zeros; i < data.size(); i++) { for (size_t i = leading_zeros; i < data.size(); i++) {
unsigned int carry = data[i]; size_t carry = static_cast<size_t>(data[i]);
for (size_t j = 0; j < digitslen; j++) { for (size_t j = 0; j < digitslen; j++) {
carry += (unsigned int)(digits[j]) << 8; carry += static_cast<size_t>(digits[j]) << 8;
digits[j] = carry % 58; digits[j] = static_cast<unsigned char>(carry % 58);
carry /= 58; carry /= 58;
} }
while (carry > 0) { while (carry > 0) {
digits[digitslen++] = carry % 58; digits[digitslen++] = static_cast<unsigned char>(carry % 58);
carry /= 58; carry /= 58;
} }
} }
@@ -56,22 +57,23 @@ std::vector<unsigned char> Base58::decode(const std::string& encoded) {
} }
// Convert from base58 // Convert from base58
std::vector<unsigned char> bytes((encoded.length() - leading_ones) * 733 / 1000 + 1); size_t bytes_size = (encoded.length() - leading_ones) * 733 / 1000 + 1;
std::vector<unsigned char> bytes(bytes_size);
size_t byteslen = 1; size_t byteslen = 1;
for (size_t i = leading_ones; i < encoded.length(); i++) { for (size_t i = leading_ones; i < encoded.length(); i++) {
unsigned int carry = ALPHABET.find(encoded[i]); size_t carry = static_cast<size_t>(ALPHABET.find(encoded[i]));
if (carry == std::string::npos) { if (carry == std::string::npos) {
throw std::invalid_argument("Invalid character in Base58 string"); throw std::invalid_argument("Invalid character in Base58 string");
} }
for (size_t j = 0; j < byteslen; j++) { for (size_t j = 0; j < byteslen; j++) {
carry += (unsigned int)(bytes[j]) * 58; carry += static_cast<size_t>(bytes[j]) * 58;
bytes[j] = carry & 0xff; bytes[j] = static_cast<unsigned char>(carry & 0xff);
carry >>= 8; carry >>= 8;
} }
while (carry > 0) { while (carry > 0) {
bytes[byteslen++] = carry & 0xff; bytes[byteslen++] = static_cast<unsigned char>(carry & 0xff);
carry >>= 8; carry >>= 8;
} }
} }

View File

@@ -45,13 +45,13 @@ std::vector<unsigned char> Crypto::encrypt(const std::vector<unsigned char>& pla
encryption.EncryptAndAuthenticate( encryption.EncryptAndAuthenticate(
ciphertext.data(), ciphertext.data(),
auth_tag.data(), auth_tag.data(),
auth_tag.size(), static_cast<int>(auth_tag.size()),
iv.data(), iv.data(),
iv.size(), static_cast<int>(iv.size()),
nullptr, nullptr,
0, // Additional authenticated data 0, // Additional authenticated data
plaintext.data(), plaintext.data(),
plaintext.size() static_cast<int>(plaintext.size())
); );
return ciphertext; return ciphertext;
@@ -79,13 +79,13 @@ std::vector<unsigned char> Crypto::decrypt(const std::vector<unsigned char>& cip
bool valid = decryption.DecryptAndVerify( bool valid = decryption.DecryptAndVerify(
plaintext.data(), plaintext.data(),
auth_tag.data(), auth_tag.data(),
auth_tag.size(), static_cast<int>(auth_tag.size()),
iv.data(), iv.data(),
iv.size(), static_cast<int>(iv.size()),
nullptr, nullptr,
0, // Additional authenticated data 0, // Additional authenticated data
ciphertext.data(), ciphertext.data(),
ciphertext.size() static_cast<int>(ciphertext.size())
); );
if(!valid) { if(!valid) {

View File

@@ -26,14 +26,14 @@ static void copy_string_to_output(const std::string& source, char** destination)
if (destination) { if (destination) {
*destination = static_cast<char*>(malloc(source.length() + 1)); *destination = static_cast<char*>(malloc(source.length() + 1));
if (*destination) { if (*destination) {
std::strcpy(*destination, source.c_str()); strcpy_s(*destination, source.length() + 1, source.c_str());
} }
} }
} }
extern "C" { extern "C" {
int create_paste(const char* server_url, const char* content, PRIVATEBIN_API int create_paste(const char* server_url, const char* content,
const char* password, const char* expiration, const char* password, const char* expiration,
const char* format, int burn_after_reading, const char* format, int burn_after_reading,
int open_discussion, char** paste_url, int open_discussion, char** paste_url,
@@ -128,7 +128,7 @@ int create_paste(const char* server_url, const char* content,
} }
} }
int upload_file(const char* server_url, const char* file_path, PRIVATEBIN_API int upload_file(const char* server_url, const char* file_path,
const char* password, const char* expiration, const char* password, const char* expiration,
int burn_after_reading, int open_discussion, int burn_after_reading, int open_discussion,
char** paste_url, char** delete_token) { char** paste_url, char** delete_token) {
@@ -248,7 +248,7 @@ int upload_file(const char* server_url, const char* file_path,
} }
} }
int get_paste(const char* server_url, const char* paste_id, PRIVATEBIN_API int get_paste(const char* server_url, const char* paste_id,
const char* key, char** content) { const char* key, char** content) {
if (!server_url || !paste_id || !key || !content) { if (!server_url || !paste_id || !key || !content) {
@@ -305,7 +305,7 @@ int get_paste(const char* server_url, const char* paste_id,
} }
} }
int delete_paste(const char* server_url, const char* paste_id, PRIVATEBIN_API int delete_paste(const char* server_url, const char* paste_id,
const char* delete_token) { const char* delete_token) {
if (!server_url || !paste_id || !delete_token) { if (!server_url || !paste_id || !delete_token) {
@@ -347,7 +347,7 @@ int delete_paste(const char* server_url, const char* paste_id,
} }
} }
void free_string(char* str) { PRIVATEBIN_API void free_string(char* str) {
if (str) { if (str) {
free(str); free(str);
} }

View File

@@ -21,9 +21,12 @@ static bool extract_paste_id_and_key(const std::string& full_url, std::string& p
} }
int main() { int main() {
const char* it = std::getenv("PRIVATEBIN_IT"); char* it = nullptr;
size_t len = 0;
_dupenv_s(&it, &len, "PRIVATEBIN_IT");
if (!it || std::string(it) == "0") { if (!it || std::string(it) == "0") {
std::cout << "[test] PRIVATEBIN_IT not set; skipping integration test." << std::endl; std::cout << "[test] PRIVATEBIN_IT not set; skipping integration test." << std::endl;
free(it);
return 0; // treat as success when integration testing is disabled return 0; // treat as success when integration testing is disabled
} }