strict file permissions of repository.yaml

Fixes #11451

Signed-off-by: shankeerthan-kasilingam <shankeerthan1995@gmail.com>
pull/11455/head
shankeerthan-kasilingam 2 years ago
parent 70a3df49d7
commit 33121a80ff

@ -213,7 +213,7 @@ func (o *repoAddOptions) run(out io.Writer) error {
f.Update(&c) f.Update(&c)
if err := f.WriteFile(o.repoFile, 0644); err != nil { if err := f.WriteFile(o.repoFile, 0600); err != nil {
return err return err
} }
fmt.Fprintf(out, "%q has been added to your repositories\n", o.name) fmt.Fprintf(out, "%q has been added to your repositories\n", o.name)

@ -67,7 +67,7 @@ func (o *repoRemoveOptions) run(out io.Writer) error {
if !r.Remove(name) { if !r.Remove(name) {
return errors.Errorf("no repo named %q found", name) return errors.Errorf("no repo named %q found", name)
} }
if err := r.WriteFile(o.repoFile, 0644); err != nil { if err := r.WriteFile(o.repoFile, 0600); err != nil {
return err return err
} }

@ -203,7 +203,7 @@ func TestWriteFile(t *testing.T) {
t.Errorf("failed to create test-file (%v)", err) t.Errorf("failed to create test-file (%v)", err)
} }
defer os.Remove(file.Name()) defer os.Remove(file.Name())
if err := sampleRepository.WriteFile(file.Name(), 0644); err != nil { if err := sampleRepository.WriteFile(file.Name(), 0600); err != nil {
t.Errorf("failed to write file (%v)", err) t.Errorf("failed to write file (%v)", err)
} }

@ -385,7 +385,7 @@ func (s *Server) StartTLS() {
CAFile: filepath.Join("../../testdata", "rootca.crt"), CAFile: filepath.Join("../../testdata", "rootca.crt"),
}) })
if err := r.WriteFile(repoConfig, 0644); err != nil { if err := r.WriteFile(repoConfig, 0600); err != nil {
panic(err) panic(err)
} }
} }
@ -400,6 +400,7 @@ func (s *Server) Stop() {
// URL returns the URL of the server. // URL returns the URL of the server.
// //
// Example: // Example:
//
// http://localhost:1776 // http://localhost:1776
func (s *Server) URL() string { func (s *Server) URL() string {
return s.srv.URL return s.srv.URL
@ -421,5 +422,5 @@ func setTestingRepository(url, fname string) error {
Name: "test", Name: "test",
URL: url, URL: url,
}) })
return r.WriteFile(fname, 0644) return r.WriteFile(fname, 0640)
} }

Loading…
Cancel
Save