MCPcopy
hub / github.com/dreadl0ck/netcap / WriteSoftware

Function WriteSoftware

decoder/stream/software/software.go:648–694  ·  view source on GitHub ↗

WriteSoftware can be used to write software to the software audit record writer.

(software []*AtomicSoftware, update func(s *AtomicSoftware))

Source from the content-addressed store, hash-verified

646
647// WriteSoftware can be used to write software to the software audit record writer.
648func WriteSoftware(software []*AtomicSoftware, update func(s *AtomicSoftware)) {
649 var newSoftwareProducts []*types.Software
650
651 // add new audit records or update existing
652 Store.Lock()
653 for _, s := range software {
654 if s == nil {
655 continue
656 }
657 s.Lock()
658
659 if s.Software == nil {
660 s.Unlock()
661 continue
662 }
663
664 ident := s.Product + "/" + s.Version
665
666 // trim version field if its too long
667 // likely a regex matched too much text
668 if len(s.Version) > 15 {
669 s.Version = s.Version[:15] + "..."
670 }
671 s.Unlock()
672 if item, ok := Store.Items[ident]; ok {
673 if update != nil {
674 update(item)
675 }
676 } else {
677 // fmt.Println(SoftwareStore.Items, s.Product, s.Version)
678 Store.Items[ident] = s
679
680 newSoftwareProducts = append(newSoftwareProducts, s.Software)
681 }
682 }
683 Store.Unlock()
684
685 if len(newSoftwareProducts) > 0 {
686 // lookup known issues with identified software
687 // NOTE: Do NOT spawn goroutine here - causes goroutine leak!
688 // These lookups are fast enough to do synchronously
689 for _, s := range newSoftwareProducts {
690 vulnerability.VulnerabilitiesLookup(s)
691 exploit.ExploitsLookup(s)
692 }
693 }
694}
695
696//// newSoftware creates a new device specific profile.
697//func newSoftware(i *decoderutils.PacketInfo) *AtomicSoftware {

Callers 5

writeHTTPFunction · 0.92
writeSoftwareFromBannerFunction · 0.92
parseHeaderValueFunction · 0.92
processSSHIdentMethod · 0.92
ParseFunction · 0.92

Calls 2

VulnerabilitiesLookupFunction · 0.92
ExploitsLookupFunction · 0.92

Tested by

no test coverage detected