mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
Merge pull request #4653 from landychan/lchan/bug-fix-3611
Nginx Resource: Add parsing support for wildcard, dot prefix, and regex
This commit is contained in:
commit
1b93755410
2 changed files with 14 additions and 1 deletions
|
@ -18,7 +18,7 @@ class NginxParser < Parslet::Parser
|
|||
end
|
||||
|
||||
rule(:standard_identifier) do
|
||||
(match("[a-zA-Z]") >> match('\S').repeat).as(:identifier) >> space >> space.repeat
|
||||
(match("[a-zA-Z~*.]") >> match('\S').repeat).as(:identifier) >> space >> space.repeat
|
||||
end
|
||||
|
||||
rule(:quoted_identifier) do
|
||||
|
|
|
@ -85,6 +85,19 @@ describe NginxParser do
|
|||
it "parses quoted identifiers for assignments" do
|
||||
_(parsestr(%{"~^\/opcache-api" 1;})).must_equal "[{:assignment=>{:identifier=>\"~^/opcache-api\"@1, :args=>[{:value=>\"1\"@17}]}}]"
|
||||
end
|
||||
|
||||
it "parses regex identifiers for assignments" do
|
||||
_(parsestr(%{~^\/opcache-api 1;})).must_equal "[{:assignment=>{:identifier=>\"~^/opcache-api\"@0, :args=>[{:value=>\"1\"@15}]}}]"
|
||||
end
|
||||
|
||||
it "parses wildcard identifiers for assignments" do
|
||||
_(parsestr(%{*.example.org qa;})).must_equal "[{:assignment=>{:identifier=>\"*.example.org\"@0, :args=>[{:value=>\"qa\"@14}]}}]"
|
||||
end
|
||||
|
||||
it "parses dot-prefixed identifiers for assignments" do
|
||||
_(parsestr(%{.example.com test;})).must_equal "[{:assignment=>{:identifier=>\".example.com\"@0, :args=>[{:value=>\"test\"@13}]}}]"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe NginxTransform do
|
||||
|
|
Loading…
Reference in a new issue