MCPcopy Create free account
hub / github.com/Adminisme/ServerScan / parseProbesFromContent

Method parseProbesFromContent

ServerScan Air/package/vscan/vscan.go:195–242  ·  view source on GitHub ↗
(content string)

Source from the content-addressed store, hash-verified

193}
194
195func (v *VScan) parseProbesFromContent(content string) {
196 var probes []Probe
197
198 var lines []string
199 linesTemp := strings.Split(content, "\n")
200 for _, lineTemp := range linesTemp {
201 lineTemp = strings.TrimSpace(lineTemp)
202 if lineTemp == "" || strings.HasPrefix(lineTemp, "#") {
203 continue
204 }
205 lines = append(lines, lineTemp)
206 }
207 if len(lines) == 0 {
208 panic("Failed to read nmap-service-probes file for probe data, 0 lines read.")
209 }
210 c := 0
211 for _, line := range lines {
212 if strings.HasPrefix(line, "Exclude ") {
213 c += 1
214 }
215 if c > 1 {
216 panic("Only 1 Exclude directive is allowed in the nmap-service-probes file")
217 }
218 }
219 l := lines[0]
220 if !(strings.HasPrefix(l, "Exclude ") || strings.HasPrefix(l, "Probe ")) {
221 panic("Parse error on nmap-service-probes file: line was expected to begin with \"Probe \" or \"Exclude \"")
222 }
223 if c == 1 {
224 v.Exclude = l[len("Exclude")+1:]
225 lines = lines[1:]
226 }
227 content = strings.Join(lines, "\n")
228 content = "\n" + content
229
230 probeParts := strings.Split(content, "\nProbe")
231 probeParts = probeParts[1:]
232
233 for _, probePart := range probeParts {
234 probe := Probe{}
235 err := probe.fromString(probePart)
236 if err != nil {
237 continue
238 }
239 probes = append(probes, probe)
240 }
241 v.Probes = probes
242}
243
244func (v *VScan) parseProbesToMapKName(probes []Probe) {
245 var probesMap = map[string]Probe{}

Callers 1

InitMethod · 0.95

Calls 1

fromStringMethod · 0.95

Tested by

no test coverage detected