Skip to content

Commit

Permalink
Merge branch 'wailsapp:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
atterpac authored Feb 14, 2024
2 parents 2801c2a + 9c3f91b commit 1b75f12
Show file tree
Hide file tree
Showing 551 changed files with 42,890 additions and 259 deletions.
38 changes: 38 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Security Policy

## Supported Versions

| Version | Supported |
| ------- | ------------------ |
| 2.x.x | :white_check_mark: |
| 3.0.x-alpha | :x: |


## Reporting a Vulnerability

If you believe you have found a security vulnerability in our project, we encourage you to let us know right away.
We will investigate all legitimate reports and do our best to quickly fix the problem.

Before reporting though, please review our security policy below.

### How to Report

To report a security vulnerability, please use GitHub's [private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability) feature. If possible, please include as much information as possible.
This may include steps to reproduce, impact of the vulnerability, and anything else you believe would help us understand the problem.
**Please do not include any sensitive or personal information in your report**.

### What to Expect

When you report a vulnerability, here's what you can expect:

- **Acknowledgement**: We will acknowledge your email within 48 hours, and you'll receive a more detailed response to your email within 72 hours indicating the next steps in handling your report.

- **Updates**: After the initial reply to your report, our team will keep you informed of the progress being made towards a fix and full announcement. These updates will be sent at least once a week.

- **Confidentiality**: We will maintain strict confidentiality of your report until the security issue is resolved.

- **Issue Resolution**: If the issue is confirmed, we will release a patch as soon as possible depending on complexity of the fix.

- **Recognition**: We recognize and appreciate every individual who helps us identify and fix vulnerabilities in our project. While we do not currently have a bounty program, we would be happy to publicly acknowledge your responsible disclosure.

We strive to make Wails safe for everyone, and we greatly appreciate the assistance of security researchers and users in helping us identify and fix vulnerabilities. Thank you for your contribution to the security of this project.
6 changes: 3 additions & 3 deletions scripts/sponsors/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 46 additions & 29 deletions v2/cmd/wails/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func buildApplication(f *flags.Build) error {
{"Tags", "[" + strings.Join(f.GetTags(), ",") + "]"},
{"Race Detector", bool2Str(f.RaceDetector)},
}...)
if len(buildOptions.OutputFile) > 0 && len(f.GetTargets()) == 1 {
if len(buildOptions.OutputFile) > 0 && f.GetTargets().Length() == 1 {
tableData = append(tableData, []string{"Output File", f.OutputFilename})
}
pterm.DefaultSection.Println("Build Options")
Expand Down Expand Up @@ -145,11 +145,16 @@ func buildApplication(f *flags.Build) error {

// Allows cancelling the build after the first error. It would be nice if targets.Each would support funcs
// returning an error.
var targetErr error
targets := f.GetTargets()
for _, target := range targets {
if !validPlatformArch.Contains(target.Platform) {
buildOptions.Logger.Println("platform '%s' is not supported - skipping. Supported platforms: %s", target.Platform, validPlatformArch.Join(","))
continue
targets.Each(func(platform string) {
if targetErr != nil {
return
}

if !validPlatformArch.Contains(platform) {
buildOptions.Logger.Println("platform '%s' is not supported - skipping. Supported platforms: %s", platform, validPlatformArch.Join(","))
return
}

desiredFilename := projectOptions.OutputFilename
Expand All @@ -158,13 +163,17 @@ func buildApplication(f *flags.Build) error {
}
desiredFilename = strings.TrimSuffix(desiredFilename, ".exe")

buildOptions.Platform = target.Platform
buildOptions.Arch = target.Arch

// Calculate platform and arch
platformSplit := strings.Split(platform, "/")
buildOptions.Platform = platformSplit[0]
buildOptions.Arch = f.GetDefaultArch()
if len(platformSplit) > 1 {
buildOptions.Arch = platformSplit[1]
}
banner := "Building target: " + buildOptions.Platform + "/" + buildOptions.Arch
pterm.DefaultSection.Println(banner)

if f.Upx && target.String() == "darwin/universal" {
if f.Upx && platform == "darwin/universal" {
pterm.Warning.Println("Warning: compress flag unsupported for universal binaries. Ignoring.")
f.Upx = false
}
Expand All @@ -173,19 +182,22 @@ func buildApplication(f *flags.Build) error {
case "linux":
if runtime.GOOS != "linux" {
pterm.Warning.Println("Crosscompiling to Linux not currently supported.")
continue
return
}
case "darwin":
if runtime.GOOS != "darwin" {
pterm.Warning.Println("Crosscompiling to Mac not currently supported.")
continue
return
}
if targets.MacTargetsCount() == 2 {
macTargets := targets.Filter(func(platform string) bool {
return strings.HasPrefix(platform, "darwin")
})
if macTargets.Length() == 2 {
buildOptions.BundleName = fmt.Sprintf("%s-%s.app", desiredFilename, buildOptions.Arch)
}
}

if len(targets) > 1 {
if targets.Length() > 1 {
// target filename
switch buildOptions.Platform {
case "windows":
Expand All @@ -207,27 +219,32 @@ func buildApplication(f *flags.Build) error {
pterm.Warning.Println("obfuscated flag overrides skipbindings flag.")
buildOptions.SkipBindings = false
}
}

if !f.DryRun {
// Start Time
start := time.Now()
if !f.DryRun {
// Start Time
start := time.Now()

compiledBinary, err := build.Build(buildOptions)
if err != nil {
pterm.Error.Println(err.Error())
return err
}
compiledBinary, err := build.Build(buildOptions)
if err != nil {
pterm.Error.Println(err.Error())
targetErr = err
return
}

buildOptions.IgnoreFrontend = true
buildOptions.CleanBinDirectory = false
buildOptions.IgnoreFrontend = true
buildOptions.CleanBinDirectory = false

// Output stats
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.\n", compiledBinary, time.Since(start).Round(time.Millisecond).String()))
// Output stats
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.\n", compiledBinary, time.Since(start).Round(time.Millisecond).String()))

outputBinaries[buildOptions.Platform+"/"+buildOptions.Arch] = compiledBinary
} else {
pterm.Info.Println("Dry run: skipped build.")
outputBinaries[buildOptions.Platform+"/"+buildOptions.Arch] = compiledBinary
} else {
pterm.Info.Println("Dry run: skipped build.")
}
})

if targetErr != nil {
return targetErr
}

if f.DryRun {
Expand Down
32 changes: 28 additions & 4 deletions v2/cmd/wails/flags/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package flags

import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"

"github.com/leaanthony/slicer"
"github.com/wailsapp/wails/v2/internal/system"
"github.com/wailsapp/wails/v2/pkg/commands/build"
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
)
Expand Down Expand Up @@ -46,15 +49,29 @@ type Build struct {
compilerPath string
userTags []string
wv2rtstrategy string // WebView2 runtime strategy
defaultArch string // Default architecture
}

func (b *Build) Default() *Build {
target := defaultTarget()
defaultPlatform := os.Getenv("GOOS")
if defaultPlatform == "" {
defaultPlatform = runtime.GOOS
}
defaultArch := os.Getenv("GOARCH")
if defaultArch == "" {
if system.IsAppleSilicon {
defaultArch = "arm64"
} else {
defaultArch = runtime.GOARCH
}
}

result := &Build{
Platform: target.Platform,
Platform: defaultPlatform + "/" + defaultArch,
WebView2: "download",
GarbleArgs: "-literals -tiny -seed=random",

defaultArch: defaultArch,
}
result.BuildCommon = result.BuildCommon.Default()
return result
Expand All @@ -71,8 +88,11 @@ func (b *Build) GetWebView2Strategy() string {
return b.wv2rtstrategy
}

func (b *Build) GetTargets() TargetsCollection {
return parseTargets(b.Platform)
func (b *Build) GetTargets() *slicer.StringSlicer {
var targets slicer.StringSlicer
targets.AddSlice(strings.Split(b.Platform, ","))
targets.Deduplicate()
return &targets
}

func (b *Build) GetCompilerPath() string {
Expand Down Expand Up @@ -124,6 +144,10 @@ func (b *Build) GetBuildModeAsString() string {
return "production"
}

func (b *Build) GetDefaultArch() string {
return b.defaultArch
}

/*
_, _ = fmt.Fprintf(w, "Frontend Directory: \t%s\n", projectOptions.GetFrontendDir())
_, _ = fmt.Fprintf(w, "Obfuscated: \t%t\n", buildOptions.Obfuscated)
Expand Down
98 changes: 0 additions & 98 deletions v2/cmd/wails/flags/common.go
Original file line number Diff line number Diff line change
@@ -1,103 +1,5 @@
package flags

import (
"fmt"
"os"
"runtime"
"strings"

"github.com/leaanthony/slicer"
"github.com/pterm/pterm"
"github.com/wailsapp/wails/v2/internal/system"
)

type Common struct {
NoColour bool `description:"Disable colour in output"`
}

type Target struct {
Platform string
Arch string
}

func defaultTarget() Target {
defaultPlatform := os.Getenv("GOOS")
if defaultPlatform == "" {
defaultPlatform = runtime.GOOS
}
defaultArch := os.Getenv("GOARCH")
if defaultArch == "" {
if system.IsAppleSilicon {
defaultArch = "arm64"
} else {
defaultArch = runtime.GOARCH
}
}

return Target{
Platform: defaultPlatform,
Arch: defaultArch,
}
}

type TargetsCollection []Target

func (c TargetsCollection) MacTargetsCount() int {
count := 0

for _, t := range c {
if strings.HasPrefix(t.Platform, "darwin") {
count++
}
}

return count
}

func (t Target) String() string {
if t.Arch != "" {
return fmt.Sprintf("%s/%s", t.Platform, t.Arch)
}

return t.Platform
}

func parseTargets(platform string) TargetsCollection {
allowedPlatforms := map[string]bool{
"windows": true,
"linux": true,
"darwin": true,
}

if !allowedPlatforms[platform] {
pterm.Error.Println("platform argument must be one of 'windows', 'linux', or 'darwin'")
os.Exit(1)
}

var result []Target
var targets slicer.StringSlicer

targets.AddSlice(strings.Split(platform, ","))
targets.Deduplicate()

targets.Each(func(platform string) {
target := Target{
Platform: "",
Arch: "",
}

platformSplit := strings.Split(platform, "/")

target.Platform = platformSplit[0]

if len(platformSplit) > 1 {
target.Arch = platformSplit[1]
} else {
target.Arch = defaultTarget().Arch
}

result = append(result, target)
})

return result
}
Loading

0 comments on commit 1b75f12

Please sign in to comment.