Skip to content

Command parameter miss-interpreted #72

@HPF97

Description

@HPF97

Describe the bug
So the problem comes from command line parameters which are interpreted as query variables or names.

Steampipe version (steampipe -v)
Steampipe v2.3.4

Plugin version (steampipe plugin list)
Exec v1.2.1

To reproduce
The goal is to make dashboards using exec module to check OS configuration, for instance presence of package in a specific version.

The following query is correctly working

  select
    *
  from (
    select
        _ctx ->> 'connection_name' as host
      , split_part(line, ',', 1) as package
      , split_part(line, ',', 2) as version
      , line
    from
      vrm_w2_man.exec_command_line  
    where
      command = 'dpkg-query -W -f=''${Package},${Version}\n''' 
    order by
      host
    , package
    ) subquery
  where package = 'zlib1g-dev' and strpos(version, '1:1.2.11') = 1;

But this query for a control not

query "query_clamav_linux_debian_package_version" {
  sql = <<-EOQ
  with 
    mes_package as (
      select
          _ctx ->> 'connection_name' as vm
        , split_part(line, ',', 1) as package
        , split_part(line, ',', 2) as version
        , line
      from
        vrm_w2_man.exec_command_line  
      where
        command = 'dpkg-query -W -f=''${Package},${Version}\n''' 
      order by
        vm
      , package
      )
  select mv.vm as resource, 'alarm' as status, mv.vm || ' : Bad version' as reason 
    from mes_package as mp 
    where mp.package = 'zlib1g-dev' and strpos(version, '1:1.2.11') = 0;
  union
  select mv.vm as resource, 'ok' as status, mv.vm || ' : Correct version' as reason 
    from mes_package as mp 
    where mp.package = 'zlib1g-dev' and strpos(version, '1:1.2.11') = 1;
  EOQ
}

The following error message is returned

Error: failed to load workspace: Internal Error: failed to load workspace: Internal Error: Failed to decode mod: failed to parse dependency: Bad Request: invalid property path: Package
(/PATH_TO_THE_BENCHMARK/CLAMAV_LINUX/clamav_linux_debian_package_version.pp:1,51-26,2)
failed to parse dependency: Bad Request: invalid property path: Version
(/PATH_TO_THE_BENCHMARK/CLAMAV_LINUX/clamav_linux_debian_package_version.pp:1,51-26,2)

${Package} and ${Version} are seen as parameter or names, instead of parameters of the command line.

Expected behavior
Command line parameters should not be interpreted as query variables or names.
OR
Documentation should inform on how to "encode" the command line with such parameters.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions