fleet/server/service/osquery_utils/gen_queries_doc.go
Eric 8fb22579ea
Reorganize Fleet documentation (#12871)
Closes: #12611

Changes:
- Added three new documentation sections `/docs/get-started/`,
`/docs/configuration` and `/docs/rest api/`
- Updated folder names: `/docs/Using-Fleet/` » `/docs/Using Fleet` and
`/docs/deploying` » `/docs/deploy/`
- Moved `/docs/using-fleet/process-events.md` to `/articles` and updated
the meta tags to change it into a guide.
- Added support for a new meta tag: `navSection`. This meta tag is used
to organize pages in the sidebar navigation on fleetdm.com/docs
- Moved `docs/using-fleet/application-security.md` and
`docs/using-fleet/security-audits.md` to the security handbook.
- Moved `docs/deploying/load-testing.md` and
`docs/deploying/debugging.md` to the engineering handbook.
- Moved the following files/folders:
- `docs/using-fleet/configuration-files/` »
`docs/configuration/configuration-files/`
- `docs/deploying/configuration.md` »
`docs/configuration/fleet-server-configuration.md`
    -  `docs/using-fleet/rest-api.md` » `docs/rest-api/rest-api.md`
- `docs/using-fleet/monitoring-fleet.md` » `docs/deploy/rest-api.md`
- Updated filenames:
- `docs/using-fleet/permissions.md` »
`docs/using-fleet/manage-access.md`
- `docs/using-fleet/adding-hosts.md` »
`docs/using-fleet/enroll-hosts.md`
    -  `docs/using-fleet/teams.md` » `docs/using-fleet/segment-hosts.md`
- `docs/using-fleet/fleet-ctl-agent-updates.md` »
`docs/using-fleet/update-agents.md`
- `docs/using-fleet/chromeos.md` »
`docs/using-fleet/enroll-chromebooks.md`
- Updated the generated markdown in `server/fleet/gen_activity_doc.go`
and `server/service/osquery_utils/gen_queries_doc.go`
- Updated the navigation sidebar and mobile dropdown links on docs pages
to group pages by their `navSection` meta tag.
- Updated fleetdm.com/docs not to show pages in the `docs/contributing/`
folder in the sidebar navigation
- Added redirects for docs pages that have moved.

.

---------

Co-authored-by: Mike Thomas <mthomas@fleetdm.com>
Co-authored-by: Rachael Shaw <r@rachael.wtf>
2023-07-27 17:40:01 -05:00

78 lines
2 KiB
Go

//go:build ignore
// +build ignore
package main
import (
"context"
"fmt"
"os"
"sort"
"strings"
"github.com/fleetdm/fleet/v4/server/config"
"github.com/fleetdm/fleet/v4/server/fleet"
"github.com/fleetdm/fleet/v4/server/service/osquery_utils"
)
func main() {
detailQueriesMap := osquery_utils.GetDetailQueries(context.Background(),
config.FleetConfig{
Vulnerabilities: config.VulnerabilitiesConfig{
DisableWinOSVulnerabilities: false,
},
App: config.AppConfig{
EnableScheduledQueryStats: true,
},
},
&fleet.AppConfig{MDM: fleet.MDM{EnabledAndConfigured: true}},
&fleet.Features{
EnableSoftwareInventory: true,
EnableHostUsers: true,
},
)
var b strings.Builder
b.WriteString(`<!-- DO NOT EDIT. This document is automatically generated. -->
# Understanding host vitals
Following is a summary of the detail queries hardcoded in Fleet used to populate the device details:
`)
type queryInfo struct {
name string
detailQuery osquery_utils.DetailQuery
}
detailQueries := make([]queryInfo, 0, len(detailQueriesMap))
for name, detailQuery := range detailQueriesMap {
detailQueries = append(detailQueries, queryInfo{
name: name,
detailQuery: detailQuery,
})
}
sort.Slice(detailQueries, func(i, j int) bool {
return detailQueries[i].name < detailQueries[j].name
})
for _, q := range detailQueries {
fmt.Fprintf(&b, "## %s\n\n", q.name)
platforms := strings.Join(q.detailQuery.Platforms, ", ")
if len(q.detailQuery.Platforms) == 0 {
platforms = "all"
}
fmt.Fprintf(&b, "- Platforms: %s\n\n", platforms)
if q.detailQuery.Discovery != "" {
fmt.Fprintf(&b, "- Discovery query:\n```sql\n%s\n```\n\n", strings.TrimSpace(q.detailQuery.Discovery))
}
fmt.Fprintf(&b, "- Query:\n```sql\n%s\n```\n\n", strings.TrimSpace(q.detailQuery.Query))
}
b.WriteString(`
<meta name="navSection" value="Dig deeper">
<meta name="pageOrderInSection" value="1600">`)
if err := os.WriteFile(os.Args[1], []byte(b.String()), 0600); err != nil {
panic(err)
}
}