Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Least-privileged data collection? #99

Open
juju4 opened this issue Aug 26, 2023 · 0 comments
Open

Least-privileged data collection? #99

juju4 opened this issue Aug 26, 2023 · 0 comments

Comments

@juju4
Copy link

juju4 commented Aug 26, 2023

Current integration requires admin privileged.
Would it be possible to use report-based ingestion which is unprivileged, like lyft/cartography#1010
It is based on SQL Query Export like

WITH
custom_tags AS (
SELECT dta.asset_id, string_agg(dt.tag_name, ', ') as custom_tags
FROM dim_tag dt
JOIN dim_tag_asset dta ON dt.tag_id=dta.tag_id
WHERE dt.tag_type = 'CUSTOM'
GROUP BY dta.asset_id
),
location_tags AS (
SELECT dta.asset_id, string_agg(dt.tag_name, ', ') as location_tags
FROM dim_tag dt
JOIN dim_tag_asset dta ON dt.tag_id=dta.tag_id
WHERE dt.tag_type = 'LOCATION'
GROUP BY dta.asset_id
),
owner_tags AS (
SELECT dta.asset_id, string_agg(dt.tag_name, ', ') as owner_tags
FROM dim_tag dt
JOIN dim_tag_asset dta ON dt.tag_id=dta.tag_id
WHERE dt.tag_type = 'OWNER'
GROUP BY dta.asset_id
),
criticality_tags AS (
SELECT dta.asset_id, string_agg(dt.tag_name, ', ') as criticality_tags
FROM dim_tag dt
JOIN dim_tag_asset dta ON dt.tag_id=dta.tag_id
WHERE dt.tag_type = 'CRITICALITY'
GROUP BY dta.asset_id
)
select da.asset_id,da.mac_address,da.ip_address,da.host_name,da.operating_system_id,da.sites,da.last_assessed_for_vulnerabilities,fa.scan_started,fa.scan_finished,fa.vulnerabilities,fa.critical_vulnerabilities,fa.moderate_vulnerabilities,fa.vulnerability_instances,fa.riskscore,fa.pci_status,dos.asset_type,dos.description,dos.vendor,dos.family,dos.name,dos.version,dos.architecture,dos.system,dos.cpe,daui.source,daui.unique_id, ct.custom_tags, lt.location_tags, ot.owner_tags, crit.criticality_tags
FROM dim_asset da
JOIN fact_asset fa USING (asset_id)
JOIN dim_operating_system dos USING (operating_system_id)
JOIN dim_asset_unique_id daui USING (asset_id)
LEFT JOIN custom_tags ct USING (asset_id)
LEFT JOIN location_tags lt USING (asset_id)
LEFT JOIN owner_tags ot USING (asset_id)
LEFT JOIN criticality_tags crit USING (asset_id)

See also https://github.com/rapid7/insightvm-sql-queries/blob/master/sql-query-export/Assets-With-All-Tags.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant