Projects STRLCPY wholeaked Commits 6a017313
🤬
  • ■ ■ ■ ■ ■ ■
    main.go
    skipped 81 lines
    82 82   
    83 83  }
    84 84   
    85  -func startProcess(baseFile string, targetsFile string, projectName string, binaryFlag bool, metadataFlag bool, watermarkFlag bool, sendgridFlag bool, sesFlag bool, smtpFlag bool, validateFlag bool) {
     85 +func startProcess(baseFile, targetsFile, projectName string, binaryFlag, metadataFlag, watermarkFlag, sendgridFlag, sesFlag, smtpFlag, validateFlag bool) {
    86 86   fmt.Println("Operation started")
    87 87   projectDir := filepath.Join(currentDir, projectName)
    88 88   dbPath := filepath.Join(projectDir, "db.csv")
    skipped 62 lines
    151 151   
    152 152  }
    153 153   
    154  -func detectWatermarkPDF(file string, signature string) bool {
     154 +func detectWatermarkPDF(file, signature string) bool {
    155 155   operatingSystem := runtime.GOOS
    156 156   var cmd *exec.Cmd
    157 157   if operatingSystem == "windows" {
    skipped 9 lines
    167 167   fmt.Println(err)
    168 168   os.Exit(1)
    169 169   }
    170  - outPath := strings.Replace(file, ".pdf", ".txt", -1)
     170 + outPath := strings.ReplaceAll(file, ".pdf", ".txt")
    171 171   content, err := ioutil.ReadFile(outPath)
    172 172   if err != nil {
    173 173   color.Red("Couldn't read the PDF file")
    skipped 6 lines
    180 180   return strings.Contains(text, signature)
    181 181  }
    182 182   
    183  -func addWatermarkPDF(file string, signature string) {
     183 +func addWatermarkPDF(file, signature string) {
    184 184   onTop := false
    185 185   update := false
    186 186   wm, _ := api.TextWatermark(signature, "sc:.9, rot:0, mo:1, op:0", onTop, update, pdfcpu.POINTS)
    187 187   api.AddWatermarksFile(file, "", nil, wm, nil)
    188 188  }
    189 189   
    190  -func detectLeak(file string, dbPath string) {
     190 +func detectLeak(file, dbPath string) {
    191 191   targets := readTargets(dbPath)
    192 192   foundFlag := false
    193 193   for _, target := range targets {
    194 194   signature := strings.Split(target, ",")[2]
    195  - name := strings.Replace(strings.Split(target, ",")[0], " ", "_", -1)
     195 + name := strings.ReplaceAll(strings.Split(target, ",")[0], " ", "_")
    196 196   fileHash := strings.Split(target, ",")[3]
    197 197   binaryFlag, hashFlag, metadataFlag, watermarkFlag := detectSignature(file, signature, fileHash)
    198 198   if hashFlag {
    skipped 34 lines
    233 233   return fmt.Sprintf("%x", h.Sum(nil))
    234 234  }
    235 235   
    236  -func applySignature(file string, signature string, binaryFlag bool, metadataFlag bool, watermarkFlag bool) {
     236 +func applySignature(file, signature string, binaryFlag, metadataFlag, watermarkFlag bool) {
    237 237   extension := filepath.Ext(file)
    238 238   if extension == ".pdf" && watermarkFlag {
    239 239   addWatermarkPDF(file, signature)
    skipped 9 lines
    249 249   
    250 250  }
    251 251   
    252  -func appendSignature(file string, signature string) {
     252 +func appendSignature(file, signature string) {
    253 253   signature = " " + signature
    254 254   f, err := os.OpenFile(file, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
    255 255   if err != nil {
    skipped 24 lines
    280 280   
    281 281  }
    282 282   
    283  -func addMetadataSignature(file string, signature string) {
     283 +func addMetadataSignature(file, signature string) {
    284 284   var metaSection string
    285 285   extension := filepath.Ext(file)
    286 286   if extension == ".docx" || extension == ".xlsx" || extension == ".pptx" {
    skipped 56 lines
    343 343   }
    344 344  }
    345 345   
    346  -func officeCompress(source string, target string) {
     346 +func officeCompress(source, target string) {
    347 347   files, err := listFiles(source)
    348 348   if err != nil {
    349 349   fmt.Println(err)
    skipped 34 lines
    384 384   }
    385 385  }
    386 386   
    387  -func exifRead(file string, field string) string {
     387 +func exifRead(file, field string) string {
    388 388   et, err := exiftool.NewExiftool()
    389 389   if err != nil {
    390 390   fmt.Printf("Error when intializing: %v\n", err)
    skipped 40 lines
    431 431   return nil
    432 432  }
    433 433   
    434  -func detectSignature(file string, signature string, hashValue string) (bool, bool, bool, bool) {
     434 +func detectSignature(file, signature, hashValue string) (bool, bool, bool, bool) {
    435 435   binaryFlag := false
    436 436   hashFlag := false
    437 437   metadataFlag := false
    skipped 98 lines
    536 536   }
    537 537  }
    538 538   
    539  -func createLocalFiles(baseFile string, projectName string, binaryFlag bool, metadataFlag bool, watermarkFlag bool) {
     539 +func createLocalFiles(baseFile, projectName string, binaryFlag, metadataFlag, watermarkFlag bool) {
    540 540   currentDir, _ := os.Getwd()
    541 541   projectDir := filepath.Join(currentDir, projectName)
    542 542   fileDir := filepath.Join(projectDir, "files")
    skipped 8 lines
    551 551   for _, target := range targets {
    552 552   if target != "" {
    553 553   signature := strings.Split(target, ",")[2]
    554  - name := strings.Replace(strings.Split(target, ",")[0], " ", "_", -1)
     554 + name := strings.ReplaceAll(strings.Split(target, ",")[0], " ", "_")
    555 555   privateDir := filepath.Join(fileDir, name)
    556 556   err := os.Mkdir(privateDir, 0777)
    557 557   if err != nil {
    skipped 2 lines
    560 560   os.Exit(1)
    561 561   }
    562 562   fileLocation := filepath.Join(privateDir, filepath.Base(baseFile))
    563  - _ = CopyFile(baseFile, fileLocation)
     563 + _ = CopyTargetFile(baseFile, fileLocation)
    564 564   applySignature(fileLocation, signature, binaryFlag, metadataFlag, watermarkFlag)
    565 565   fileHash = getHash(fileLocation)
    566 566   updatedDB += target + "," + fileHash + "," + fileLocation + "\n"
    skipped 8 lines
    575 575   }
    576 576  }
    577 577   
    578  -func CopyFile(src, dst string) error {
     578 +func CopyTargetFile(src, dst string) error {
    579 579   in, err := os.Open(src)
    580 580   if err != nil {
    581 581   return err
    skipped 12 lines
    594 594   return cerr
    595 595  }
    596 596   
    597  -func Unzip(src string, destination string) ([]string, error) {
     597 +func Unzip(src, destination string) ([]string, error) {
    598 598   var filenames []string
    599 599   r, err := zip.OpenReader(src)
    600 600   if err != nil {
    skipped 50 lines
    651 651   return contentType
    652 652  }
    653 653   
    654  -func sendWithSendgrid(toName string, toEmail string, fromName string, fromEmail string, subject string, bodyFile string, contentType string, attachment string) {
     654 +func sendWithSendgrid(toName, toEmail, fromName, fromEmail, subject, bodyFile, contentType, attachment string) {
    655 655   configFile, err := os.Open("CONFIG")
    656 656   if err != nil {
    657 657   color.Red("Can't read the CONFIG file")
    skipped 4 lines
    662 662   scanner := bufio.NewScanner(configFile)
    663 663   for scanner.Scan() {
    664 664   if strings.Contains(scanner.Text(), "SENDGRID_API_KEY") {
    665  - apiKey := strings.TrimSpace(strings.Replace(strings.Split(scanner.Text(), "=")[1], "\"", "", -1))
     665 + apiKey := strings.TrimSpace(strings.ReplaceAll(strings.Split(scanner.Text(), "=")[1], "\"", ""))
    666 666   if apiKey == "" {
    667 667   fmt.Println("No Sendgrid API Key is set in the CONFIG file")
    668 668   os.Exit(1)
    skipped 5 lines
    674 674   os.Exit(1)
    675 675   }
    676 676   m := mail.NewV3Mail()
    677  - newBody := strings.Replace(string(body), "{{Name}}", toName, -1)
     677 + newBody := strings.ReplaceAll(string(body), "{{Name}}", toName)
    678 678   from := mail.NewEmail(fromName, fromEmail)
    679 679   to := mail.NewEmail(toName, toEmail)
    680 680   content := mail.NewContent("text/plain", newBody)
    skipped 54 lines
    735 735   }
    736 736  }
    737 737   
    738  -func sendWithSES(toName string, toEmail string, fromName string, fromEmail string, subject string, bodyFile string, contentType string, attachment string, region string) {
     738 +func sendWithSES(toName, toEmail, fromName, fromEmail, subject, bodyFile, contentType, attachment, region string) {
    739 739   sess, err := session.NewSession(&aws.Config{
    740 740   Region: aws.String(region)},
    741 741   )
    skipped 8 lines
    750 750   fmt.Println(err)
    751 751   os.Exit(1)
    752 752   }
    753  - newBody := strings.Replace(string(body), "{{Name}}", toName, -1)
     753 + newBody := strings.ReplaceAll(string(body), "{{Name}}", toName)
    754 754   msg := gomail.NewMessage()
    755 755   svc := ses.New(sess)
    756 756   msg.SetAddressHeader("From", fromEmail, fromName)
    skipped 32 lines
    789 789   color.Green("Email sent successfully to : " + toName + " (" + toEmail + ")")
    790 790  }
    791 791   
    792  -func sendWithSMTP(toName string, toEmail string, fromName string, fromEmail string, subject string, bodyFile string, contentType string, attachment string) {
     792 +func sendWithSMTP(toName, toEmail, fromName, fromEmail, subject, bodyFile, contentType, attachment string) {
    793 793   configs := parseConfigFile()
    794 794   
    795 795   if configs["SMTP_SERVER"] == "" {
    skipped 16 lines
    812 812   fmt.Println(err)
    813 813   os.Exit(1)
    814 814   }
    815  - newBody := strings.Replace(string(body), "{{Name}}", toName, -1)
     815 + newBody := strings.ReplaceAll(string(body), "{{Name}}", toName)
    816 816   if contentType == "text" {
    817 817   m.SetBody("text/plain", newBody)
    818 818   } else if contentType == "html" {
    skipped 33 lines
    852 852   for scanner.Scan() {
    853 853   if strings.Contains(scanner.Text(), "=") {
    854 854   key := strings.TrimSpace(strings.Split(scanner.Text(), "=")[0])
    855  - value := strings.TrimSpace(strings.Replace(strings.Split(scanner.Text(), "=")[1], "\"", "", -1))
     855 + value := strings.TrimSpace(strings.ReplaceAll(strings.Split(scanner.Text(), "=")[1], "\"", ""))
    856 856   config[key] = value
    857 857   }
    858 858   }
    skipped 3 lines
Please wait...
Page is in error, reload to recover