concourse / concourse

Potential issue in filepath.Join() function calls GO-W4001
Anti-pattern
Major
5 months agoa year old
".git/HEAD" contains a path separator
149			err = os.Mkdir(filepath.Join(input1, ".git/objects"), 0755)
150			Expect(err).NotTo(HaveOccurred())
151
152			gitHEADPath := filepath.Join(input1, ".git/HEAD")153			err = os.WriteFile(gitHEADPath, []byte(`ref: refs/heads/master`), 0644)
154			Expect(err).NotTo(HaveOccurred())
155
".git/objects" contains a path separator
146			err = os.Mkdir(filepath.Join(input1, ".git/refs"), 0755)
147			Expect(err).NotTo(HaveOccurred())
148
149			err = os.Mkdir(filepath.Join(input1, ".git/objects"), 0755)150			Expect(err).NotTo(HaveOccurred())
151
152			gitHEADPath := filepath.Join(input1, ".git/HEAD")
".git/refs" contains a path separator
143			err = os.Mkdir(filepath.Join(input1, ".git"), 0755)
144			Expect(err).NotTo(HaveOccurred())
145
146			err = os.Mkdir(filepath.Join(input1, ".git/refs"), 0755)147			Expect(err).NotTo(HaveOccurred())
148
149			err = os.Mkdir(filepath.Join(input1, ".git/objects"), 0755)
"/hosts" contains a path separator
82}
83
84func (s *FileStoreSuite) TestContainerIpLookup() {
85	_, err := s.store.Create(filepath.Join("some-handle", "/hosts"), []byte("10.80.0.42 some-handle\n"))86	s.NoError(err)
87
88	ip, err := s.store.ContainerIpLookup("some-handle")
"/hosts" contains a path separator
 87func (f fileStore) ContainerIpLookup(handle string) (string, error) {
 88	absPath := filepath.Join(f.root, handle)
 89
 90	hc := txeh.HostsConfig{ReadFilePath: filepath.Join(absPath, "/hosts")} 91	hosts, err := txeh.NewHosts(&hc)
 92	if err != nil {
 93		return "", fmt.Errorf("error reading hosts file: %w", err)