Skip to content

Commit 0ba11c2

Browse files
authored
fix(dbt): use latest sbom package source names (#2874)
* fix(dbt): add sbom staging model * refactor(dbt): update sbom/package logic * chore(docs): update tutorial example * fix(dbt): add playground sources * fix(dbt): applies artifact cases at staging model level
1 parent 558e8ea commit 0ba11c2

File tree

6 files changed

+68
-42
lines changed

6 files changed

+68
-42
lines changed

apps/docs/docs/tutorials/dependencies.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ select distinct
210210
sboms.to_package_artifact_name = package_owners.package_artifact_name
211211
and sboms.to_package_artifact_source = package_owners.package_artifact_source
212212
where
213-
sboms.to_package_artifact_source in ('NPM','RUST','GO','PIP')
213+
sboms.to_package_artifact_source in ('NPM','CARGO','GOLANG','PYPI')
214214
and package_owners.package_owner_artifact_namespace is not null
215215
and concat(sboms.from_artifact_namespace, '/', sboms.from_artifact_name)
216216
in ('prysmaticlabs/prysm','sigp/lighthouse','consensys/teku','status-im/nimbus-eth2',
@@ -240,7 +240,7 @@ query = """
240240
sboms.to_package_artifact_name = package_owners.package_artifact_name
241241
and sboms.to_package_artifact_source = package_owners.package_artifact_source
242242
where
243-
sboms.to_package_artifact_source in ('NPM','RUST','GO','PIP')
243+
sboms.to_package_artifact_source in ('NPM','CARGO','GOLANG','PYPI')
244244
and package_owners.package_owner_artifact_namespace is not null
245245
and concat(sboms.from_artifact_namespace, '/', sboms.from_artifact_name)
246246
in ('prysmaticlabs/prysm','sigp/lighthouse','consensys/teku','status-im/nimbus-eth2',

warehouse/dbt/models/base_playground_sources.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: 2
2+
13
sources:
24
- name: base_playground
35

@@ -95,6 +97,9 @@ sources:
9597

9698
- name: ossd_collections
9799
identifier: base_playground__ossd_collections
98-
100+
99101
- name: ossd_repositories
100-
identifier: base_playground__ossd_repositories
102+
identifier: base_playground__ossd_repositories
103+
104+
- name: ossd_sbom
105+
identifier: base_playground__ossd_sbom

warehouse/dbt/models/intermediate/directory/int_packages.sql

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,10 @@ select
2727
deps_dev.package_version,
2828
deps_dev.package_github_owner,
2929
deps_dev.package_github_repo,
30-
case
31-
when deps_dev.package_artifact_source = 'CARGO' then 'RUST'
32-
when deps_dev.package_artifact_source = 'NPM' then 'NPM'
33-
when deps_dev.package_artifact_source = 'PYPI' then 'PIP'
34-
when deps_dev.package_artifact_source = 'GO' then 'GO'
35-
when deps_dev.package_artifact_source = 'MAVEN' then 'MAVEN'
36-
when deps_dev.package_artifact_source = 'NUGET' then 'NUGET'
37-
else 'UNKNOWN'
38-
end as sbom_artifact_source,
3930
(
4031
deps_dev.package_github_owner = latest_versions.current_owner
41-
and deps_dev.package_github_repo = latest_versions.current_repo)
42-
as is_current_owner
32+
and deps_dev.package_github_repo = latest_versions.current_repo
33+
) as is_current_owner
4334
from deps_dev
4435
left join latest_versions
4536
on

warehouse/dbt/models/intermediate/directory/int_sbom_artifacts.sql

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
1-
with ranked_snapshots as (
2-
select
3-
artifact_source,
4-
package_source,
5-
package_version,
6-
snapshot_at,
7-
lower(artifact_namespace) as artifact_namespace,
8-
lower(artifact_name) as artifact_name,
9-
lower(package) as package,
10-
row_number() over (
11-
partition by
12-
artifact_source,
13-
artifact_namespace,
14-
artifact_name,
15-
package_source,
16-
package,
17-
package_version
18-
order by snapshot_at asc
19-
) as row_num
20-
from {{ source('ossd', 'sbom') }}
21-
),
22-
23-
sbom_artifacts as (
1+
with sbom_artifacts as (
242
select
253
artifact_source,
264
artifact_namespace,
@@ -29,13 +7,24 @@ sbom_artifacts as (
297
package,
308
package_version,
319
snapshot_at
32-
from ranked_snapshots
33-
where row_num = 1
10+
from {{ ref('stg_ossd__current_sbom') }}
11+
where package_source in (
12+
'CARGO',
13+
'GOLANG',
14+
'NPM',
15+
'PYPI'
16+
)
3417
),
3518

3619
deps_dev_packages as (
3720
select distinct
38-
sbom_artifact_source,
21+
case
22+
when package_artifact_source = 'CARGO' then 'CARGO'
23+
when package_artifact_source = 'GO' then 'GOLANG'
24+
when package_artifact_source = 'NPM' then 'NPM'
25+
when package_artifact_source = 'PYPI' then 'PYPI'
26+
else 'OTHER'
27+
end as sbom_artifact_source,
3928
package_artifact_name,
4029
package_github_owner,
4130
package_github_repo

warehouse/dbt/models/playground_sources.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,7 @@ sources:
9797
identifier: base_playground__ossd_collections
9898

9999
- name: ossd_repositories
100-
identifier: base_playground__ossd_repositories
100+
identifier: base_playground__ossd_repositories
101+
102+
- name: ossd_sbom
103+
identifier: base_playground__ossd_sbom
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{
2+
config(
3+
materialized='table'
4+
)
5+
}}
6+
7+
{#
8+
The most recent view of sboms from the ossd dagster source.
9+
#}
10+
11+
with ranked_sboms as (
12+
select
13+
snapshot_at,
14+
lower(artifact_namespace) as artifact_namespace,
15+
lower(artifact_name) as artifact_name,
16+
upper(artifact_source) as artifact_source,
17+
lower(package) as package,
18+
upper(package_source) as package_source,
19+
lower(package_version) as package_version,
20+
row_number()
21+
over (
22+
partition by artifact_namespace, artifact_name, artifact_source, package, package_source
23+
order by snapshot_at desc
24+
)
25+
as row_num
26+
from {{ oso_source('ossd', 'sbom') }}
27+
)
28+
29+
select
30+
artifact_namespace,
31+
artifact_name,
32+
artifact_source,
33+
package,
34+
package_source,
35+
package_version,
36+
snapshot_at
37+
from ranked_sboms
38+
where row_num = 1

0 commit comments

Comments
 (0)