Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FixCmd = &cobra.Command{ Use: "fix", Aliases: []string{"f"}, Short: "Fix missing index.php files and permissions on a prestashop worktree.", Long: "Fix missing index.php files and permissions on a prestashop worktree.", Run: func(cmd *cobra.Command, args []string) { psDefineInc := filepath.Join(workDir, psCheckFilePath) if _, err := os.Stat(psDefineInc); os.IsNotExist(err) { log.Fatalf("Sounds like it is not a prestashop workdir. Could not find file '%s'\n", psDefineInc) } indexPHP := bytes.NewBufferString("") indexTemplate, _ := template.New("").Parse(psIndexTemplate) indexTemplate.Execute(indexPHP, map[string]string{ "project": fmt.Sprintf("%s", project), "company": fmt.Sprintf("%s", company), "author": fmt.Sprintf("%s", author), "email": fmt.Sprintf("%s", email), "year": time.Now().Format("Y"), }) godirwalk.Walk(workDir, &godirwalk.Options{ Callback: func(osPathname string, de *godirwalk.Dirent) error { if !de.IsDir() { err := os.Chmod(osPathname, 0644) if err != nil { return err } else { log.Infof("Changed file '%s' permissions to 0644\n", osPathname) } } else { err := os.Chmod(osPathname, 0755) if err != nil { return err } else { log.Infof("Changed directory '%s' permissions to 0755\n", osPathname) } if inSliceContains(osPathname, skipDirectories, false) { return nil } indexFile := filepath.Join(osPathname, "index.php") if _, err := os.Stat(indexFile); os.IsNotExist(err) { log.Warnf("Missing index.php at '%s'\n", osPathname) if !dryRun { err := ioutil.WriteFile(indexFile, indexPHP.Bytes(), 0644) return err } } else { log.Infof("Success 'index.php' exists at '%s'\n", osPathname) } } return nil }, Unsorted: !sorted, }) }, }
View Source
var RootCmd = &cobra.Command{
Use: "ps2security",
Short: "ps2security is an helper to add missing index.php and fix permissions on files and directories.",
Long: `ps2security is an helper to add missing index.php and fix permissions on files and directories.`,
}
RootCmd is the root command for ovh-qa
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.