detect-it-easy added to fileview
This commit is contained in:
		
							parent
							
								
									061281bba9
								
							
						
					
					
						commit
						3ff15ae5d9
					
				
					 3 changed files with 65 additions and 10 deletions
				
			
		| 
						 | 
					@ -25,7 +25,13 @@ func FileViewWebHandler(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
		http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
							http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	component := FileView(file, fileProperties)
 | 
						diec, err := database.GetFileDiec(file.ID) 
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							slog.Error("Error getting Detect-It-Easy in FileViewWebHandler", "error", err, "file-uuid", r.PathValue("uuid"))
 | 
				
			||||||
 | 
							http.Error(w, err.Error(), http.StatusInternalServerError)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						component := FileView(file, fileProperties, diec)
 | 
				
			||||||
	err = component.Render(r.Context(), w)
 | 
						err = component.Render(r.Context(), w)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		slog.Error("Error rendering in FileViewWebHandler", "error", err)
 | 
							slog.Error("Error rendering in FileViewWebHandler", "error", err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,8 +6,9 @@ import "git.jmbit.de/jmb/scanfile/server/web/templui/components/modal"
 | 
				
			||||||
import "git.jmbit.de/jmb/scanfile/server/internal/processing"
 | 
					import "git.jmbit.de/jmb/scanfile/server/internal/processing"
 | 
				
			||||||
import "fmt"
 | 
					import "fmt"
 | 
				
			||||||
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
 | 
					import "git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
 | 
				
			||||||
 | 
					import "git.jmbit.de/jmb/scanfile/server/internal/database"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ FileView(file sqlc.File, fileProperties sqlc.FileProperty) {
 | 
					templ FileView(file sqlc.File, fileProperties sqlc.FileProperty, diec database.Diec) {
 | 
				
			||||||
  @Base(file.Name) {
 | 
					  @Base(file.Name) {
 | 
				
			||||||
    <div class="flex space-x-4 pb-4">
 | 
					    <div class="flex space-x-4 pb-4">
 | 
				
			||||||
      <h1 class="text-4xl">{file.Name}</h1>
 | 
					      <h1 class="text-4xl">{file.Name}</h1>
 | 
				
			||||||
| 
						 | 
					@ -15,12 +16,11 @@ templ FileView(file sqlc.File, fileProperties sqlc.FileProperty) {
 | 
				
			||||||
      @FileViewDownloadModal(file.ID.String())
 | 
					      @FileViewDownloadModal(file.ID.String())
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div class="grid grid-cols-2 gap-4">
 | 
					    <div class="grid grid-cols-2 gap-4">
 | 
				
			||||||
    @FileViewGenericTable(file, fileProperties)
 | 
					    @FileViewGenericTable(file, fileProperties, diec)
 | 
				
			||||||
    if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
 | 
					    if processing.TypeFromMime(file.Mimetype) == processing.TypeMSOffice {
 | 
				
			||||||
      @FileViewMsofficeLoader(file.ID.String())
 | 
					      @FileViewMsofficeLoader(file.ID.String())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,8 +5,9 @@ import "git.jmbit.de/jmb/scanfile/server/web/templui/components/table"
 | 
				
			||||||
import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
 | 
					import "git.jmbit.de/jmb/scanfile/server/web/templui/components/button"
 | 
				
			||||||
import "encoding/hex"
 | 
					import "encoding/hex"
 | 
				
			||||||
import "fmt"
 | 
					import "fmt"
 | 
				
			||||||
 | 
					import "git.jmbit.de/jmb/scanfile/server/internal/database"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
 | 
					templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty, diec database.Diec) {
 | 
				
			||||||
    <div class="w-full">
 | 
					    <div class="w-full">
 | 
				
			||||||
      <h2 class="text-3xl">Generic Information</h2>
 | 
					      <h2 class="text-3xl">Generic Information</h2>
 | 
				
			||||||
      @table.Table() {
 | 
					      @table.Table() {
 | 
				
			||||||
| 
						 | 
					@ -71,7 +72,7 @@ templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if fileProperties.LibmagicApple.Valid {
 | 
					        if fileProperties.LibmagicApple.Valid && fileProperties.LibmagicApple.String != "UNKNUNKN" {
 | 
				
			||||||
          @table.Row() {
 | 
					          @table.Row() {
 | 
				
			||||||
            @table.Cell() {
 | 
					            @table.Cell() {
 | 
				
			||||||
              Apple Filetype
 | 
					              Apple Filetype
 | 
				
			||||||
| 
						 | 
					@ -90,17 +91,65 @@ templ FileViewGenericTable(file sqlc.File, fileProperties sqlc.FileProperty) {
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    @DiecInfo(diec)
 | 
				
			||||||
 | 
					    @OtherServices(hex.EncodeToString(fileProperties.Sha256))
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <p class="p-1">Look for this file on other services</p>
 | 
					templ DiecInfo(diec database.Diec) {
 | 
				
			||||||
 | 
					    <h3 class="text-2xl">Detect-It-Easy information</h3>
 | 
				
			||||||
 | 
					      @table.Table() {
 | 
				
			||||||
 | 
					        @table.Header() {
 | 
				
			||||||
 | 
					          @table.Head() {
 | 
				
			||||||
 | 
					            Info
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          @table.Head() {
 | 
				
			||||||
 | 
					            Name
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          @table.Head() {
 | 
				
			||||||
 | 
					            Type
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          @table.Head() {
 | 
				
			||||||
 | 
					            Details
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          @table.Head() {
 | 
				
			||||||
 | 
					            Version
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        @table.Body() {
 | 
				
			||||||
 | 
					          for _, row := range diec.Data.Detects[0].Values {
 | 
				
			||||||
 | 
					            @table.Row() {
 | 
				
			||||||
 | 
					              @table.Cell() {
 | 
				
			||||||
 | 
					                {row.Info}
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					              @table.Cell() {
 | 
				
			||||||
 | 
					                {row.Name}
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					              @table.Cell() {
 | 
				
			||||||
 | 
					                {row.Type}
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					              @table.Cell() {
 | 
				
			||||||
 | 
					                {row.String}
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					              @table.Cell() {
 | 
				
			||||||
 | 
					                {row.Version}
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					templ OtherServices(sha256 string) {
 | 
				
			||||||
 | 
					    <h3 class="text-2xl">Look for this file on other Services</h3>
 | 
				
			||||||
    <div class="flex space-x-4 pb-4">
 | 
					    <div class="flex space-x-4 pb-4">
 | 
				
			||||||
       @button.Button(button.Props{
 | 
					       @button.Button(button.Props{
 | 
				
			||||||
         Variant: button.VariantOutline,
 | 
					         Variant: button.VariantOutline,
 | 
				
			||||||
         Href: fmt.Sprintf("https://www.virustotal.com/gui/file/%s", hex.EncodeToString(fileProperties.Sha256)),
 | 
					         Href: fmt.Sprintf("https://www.virustotal.com/gui/file/%s", sha256),
 | 
				
			||||||
         }) {VirusTotal}
 | 
					         }) {VirusTotal}
 | 
				
			||||||
       @button.Button(button.Props{
 | 
					       @button.Button(button.Props{
 | 
				
			||||||
         Variant: button.VariantOutline,
 | 
					         Variant: button.VariantOutline,
 | 
				
			||||||
         Href: fmt.Sprintf("https://bazaar.abuse.ch/sample/%s", hex.EncodeToString(fileProperties.Sha256)),
 | 
					         Href: fmt.Sprintf("https://bazaar.abuse.ch/sample/%s", sha256),
 | 
				
			||||||
         }) {Malware Bazaar}
 | 
					         }) {Malware Bazaar}
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue