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

RegExp in processes resource can't match long-run process #1332

Closed
Wing924 opened this Issue Nov 29, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@Wing924
Contributor

Wing924 commented Nov 29, 2016

Description

It use ([^ ]+) to match each ps columns in file: lib/resources/processes.rb.
But as man page of ps says, start format may be mmm dd or HH:MM:SS.
Because mmm dd comtains space, it can't be match with the RegExp.

man of ps

start      STARTED  time the command started. If the process was started less than 24 hours ago, 
              the output format is  "HH:MM:SS", else it is "  mmm dd" 
              (where mmm is a three-letter month name). 
              See also lstart, bsdstart, start_time, and stime.

InSpec and Platform Version

Tested against 1.5 and 1.6

Replication Case

# assume httpd processes are running more than 24 hours
describe processes('httpd') do
  its('list.length') { should be >= 1 }
end

It will output

 ×  httpd process: Process httpd should be running (expected: >= 1
          got:    0)
     ×  Processes list.length should be >= 1
     expected: >= 1
          got:    0

Possible Solutions

Change 9th ([^ ]+) to (\w{3} \d{2}|\d{2}:\d{2}:\d{2})

Wing924 pushed a commit to Wing924/inspec that referenced this issue Nov 29, 2016

Wei, He
fix bug: RegExp in processes resource can't match long-run process in…
…spec#1332

Signed-off-by: Wei, He <weihe924stephen@gmail.com>

Wing924 pushed a commit to Wing924/inspec that referenced this issue Nov 29, 2016

Wei, He
fix bug: RegExp in processes resource can't match long-run process in…
…spec#1332

Signed-off-by: Wei, He <weihe924stephen@gmail.com>
@Wing924

This comment has been minimized.

Show comment
Hide comment
@Wing924

Wing924 Nov 29, 2016

Contributor

CI test failed on Oracle-linux installing openssh-server phase :(

Contributor

Wing924 commented Nov 29, 2016

CI test failed on Oracle-linux installing openssh-server phase :(

Wing924 pushed a commit to Wing924/inspec that referenced this issue Nov 30, 2016

Wei, He
add testcase for inspec#1332
Signed-off-by: Wei, He <weihe924stephen@gmail.com>

Wing924 pushed a commit to Wing924/inspec that referenced this issue Nov 30, 2016

Wei, He
add testcase for inspec#1332
Signed-off-by: Wei, He <weihe924stephen@gmail.com>

Wing924 pushed a commit to Wing924/inspec that referenced this issue Nov 30, 2016

Wei, He
add testcase for inspec#1332
Signed-off-by: Wei, He <weihe924stephen@gmail.com>

Wing924 pushed a commit to Wing924/inspec that referenced this issue Nov 30, 2016

Wei, He
add testcase for inspec#1332
Signed-off-by: Wei, He <weihe924stephen@gmail.com>

chris-rock added a commit that referenced this issue Nov 30, 2016

Merge pull request #1333 from Wing924/fix_regexp_in_processes
fix bug: RegExp in processes resource can't match long-run process #1332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment