PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: amacneil/dbmate (go)

Issue:
Credentials are leaked to stderr when database URL is malformed
Let's say I give Dbmate a malformed database URL. In this case, it has a base64-encoded password which I forgot to properly URL-encode.
```bash
export DATABASE_URL=mysql://username:otS33+tb/e4=@localhost:3306/database
```
If I run `dbmate up`, I get the following output to stderr:
```
Error: parse "mysql://username:otS33+tb/e4=@localhost:3306/database": invalid port ":otS33+tb" after host
```
This leaks the database credentials to stderr, which could be problematic if stderr is being logged somewhere. I ran into this problem when trying to run Dbmate in a serverless function, which is a reasonable use-case for accessing a database which might be locked behind a VPC.

Do you think it's reasonable to mask the database credentials in the output?

Pull request:
Redact passwords in error messages
Fixes #144

Patch:
diff --git a/main.go b/main.go
index 8452277..99909f7 100644
--- a/main.go
+++ b/main.go
@@ -5,6 +5,7 @@ import (
 	"log"
 	"net/url"
 	"os"
+	"regexp"
 
 	"github.com/joho/godotenv"
 	"github.com/urfave/cli"
@@ -19,7 +20,8 @@ func main() {
 	err := app.Run(os.Args)
 
 	if err != nil {
-		_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
+		errText := redactLogString(fmt.Sprintf("Error: %s\n", err))
+		_, _ = fmt.Fprint(os.Stderr, errText)
 		os.Exit(2)
 	}
 }
@@ -219,3 +221,10 @@ func getDatabaseURL(c *cli.Context) (u *url.URL, err error) {
 
 	return url.Parse(value)
 }
+
+// redactLogString attempts to redact passwords from errors
+func redactLogString(in string) string {
+	re := regexp.MustCompile("([a-zA-Z]+://[^:]+:)[^@]+@")
+
+	return re.ReplaceAllString(in, "${1}********@")
+}


Test patch:
diff --git a/main_test.go b/main_test.go
index 1d20d06..d6922db 100644
--- a/main_test.go
+++ b/main_test.go
@@ -35,3 +35,23 @@ func TestGetDatabaseUrl(t *testing.T) {
 	require.Equal(t, "example.org", u.Host)
 	require.Equal(t, "/db", u.Path)
 }
+
+func TestRedactLogString(t *testing.T) {
+	examples := []struct {
+		in       string
+		expected string
+	}{
+		{"normal string",
+			"normal string"},
+		// malformed URL example (note forward slash in password)
+		{"parse \"mysql://username:otS33+tb/e4=@localhost:3306/database\": invalid",
+			"parse \"mysql://username:********@localhost:3306/database\": invalid"},
+		// invalid port, but probably not a password since there is no @
+		{"parse \"mysql://localhost:abc/database\": invalid",
+			"parse \"mysql://localhost:abc/database\": invalid"},
+	}
+
+	for _, ex := range examples {
+		require.Equal(t, ex.expected, redactLogString(ex.in))
+	}
+}
Repository: railwayapp/nixpacks (rust)

Issue:
Add RAILS_LOG_TO_STDOUT=enabled by default to RoR projects 
### Feature request

Some Ruby projects doesn't send application logs to stdout once started.
`RAILS_LOG_TO_STDOUT=enabled ` should fix the issue

It would be better to have it as the default behavior!

### Motivation

_No response_

### Contribution

_No response_

Pull request:
feat: enable `RAILS_LOG_TO_STDOUT`
<!-- Thanks for sending a pull request! -->
<!-- Please add a useful description explaining what this PR does -->

This PR sets `RAILS_LOG_TO_STDOUT=enabled` if ruby on rails app is detected.

Fixes #559 
<!-- PR Checklist  -->
- [x] Tests are added/updated if needed
<!-- - [ ] Docs are updated if needed  -->

Patch:
diff --git a/src/providers/ruby.rs b/src/providers/ruby.rs
index 42b2433..bd72135 100644
--- a/src/providers/ruby.rs
+++ b/src/providers/ruby.rs
@@ -114,7 +114,7 @@ impl RubyProvider {
 
     fn get_environment_variables(&self, app: &App) -> Result<EnvironmentVariables> {
         let ruby_version = self.get_ruby_version(app)?;
-        Ok(EnvironmentVariables::from([
+        let mut env_vars = EnvironmentVariables::from([
             ("BUNDLE_GEMFILE".to_string(), "/app/Gemfile".to_string()),
             (
                 "GEM_PATH".to_string(),
@@ -127,7 +127,11 @@ impl RubyProvider {
                 "GEM_HOME".to_string(),
                 format!("/usr/local/rvm/gems/{}", ruby_version),
             ),
-        ]))
+        ]);
+        if self.is_rails_app(app) {
+            env_vars.insert("RAILS_LOG_TO_STDOUT".to_string(), "enabled".to_string());
+        }
+        Ok(env_vars)
     }
 
     fn get_start_command(&self, app: &App) -> Option<String> {


Test patch:
diff --git a/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap b/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap
index 1314f36..14ba927 100644
--- a/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap
+++ b/tests/snapshots/generate_plan_tests__ruby_rails_postgres.snap
@@ -9,7 +9,8 @@ expression: plan
     "BUNDLE_GEMFILE": "/app/Gemfile",
     "GEM_HOME": "/usr/local/rvm/gems/3.1.2",
     "GEM_PATH": "/usr/local/rvm/gems/3.1.2:/usr/local/rvm/gems/3.1.2@global",
-    "NIXPACKS_METADATA": "Ruby"
+    "NIXPACKS_METADATA": "Ruby",
+    "RAILS_LOG_TO_STDOUT": "enabled"
   },
   "phases": {
     "build": {