Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find out how escaping works with bfg #85

Open
github-actions bot opened this issue Mar 8, 2024 · 1 comment
Open

find out how escaping works with bfg #85

github-actions bot opened this issue Mar 8, 2024 · 1 comment
Assignees

Comments

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2024

(seems not to be document; single and double quotes do not work)

// TODO: find out how escaping works with bfg

	cmd.Dir = directoryToScan
	out, err := cmd.Output()
	if err != nil {
		// This is expected to happen when there are no search results.
		if err.Error() == "exit status 1" {
			return string(out), nil
		}

		return "", err
	}

	return string(out), nil
}

func downloadBfg() error {
	err := downloadDependency("bfg", "jar",
		"https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar")
	return err
}

func removeSecret(secret string) error {
	err := downloadBfg()
	if err != nil {
		return err
	}

	pathReplacementsFile := dependenciesDir + "/" + "replacements"

	const filePermissions = 0600
	defer os.Remove(pathReplacementsFile)
	// TODO: find out how escaping works with bfg
	// (seems not to be document; single and double quotes do not work)
	err = os.WriteFile(pathReplacementsFile, []byte(secret), filePermissions)
	if err != nil {
		return err
	}

	pathBfg := dependenciesDir + "/bfg.jar"

	cmd := exec.Command("java", "-jar", pathBfg, "--replace-text", pathReplacementsFile, ".")
	cmd.Dir = directoryToScan
	_, err = cmd.Output()

	if err != nil {
		return err
	}

	return nil
}
@github-actions github-actions bot added the todo label Mar 8, 2024
@m1cm1c m1cm1c self-assigned this Mar 8, 2024
@m1cm1c
Copy link
Collaborator

m1cm1c commented Mar 18, 2024

es scheint aktuell überhaupt nicht möglich zu sein, mit einem der angebundenen detektoren ein geheimnis zu entdecken, das ==> enthält => ice box

dokumentation zum escaping habe ich auch nicht gefunden, aber es gibt andere leute mit dem gleichen problem, die dann teilweise bfg geforkt haben: rtyley/bfg-repo-cleaner#77 (comment) => vermutlich gibt es kein escaping

etwas weitere informationen dazu, wie bfg die replacement strings interpretiert: rtyley/bfg-repo-cleaner#77 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant