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

tools: modules: committer_count: Parse date argument with Time.parse #17830

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

bcoles
Copy link
Contributor

@bcoles bcoles commented Mar 28, 2023

I'm not sure when or why this broke. This tool has had no meaningful updates since 2013.

Parsing the date in format YYYY-MM-DD is kind of important, as this is what the script does by default when no argument is provided:

date = ARGV[0] || "2005-03-22" # A day before the first SVN commit.

This crashes with Time.new. It does not crash with Time.parse.

Before

# ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]

# ./tools/modules/committer_count.rb | head
<internal:timev>:310:in `initialize': invalid value for Integer(): "2005-03-22" (ArgumentError)
	from ./tools/modules/committer_count.rb:47:in `new'
	from ./tools/modules/committer_count.rb:47:in `parse_date'
	from ./tools/modules/committer_count.rb:52:in `<main>'

# ./tools/modules/committer_count.rb 2023-03-23 | head
<internal:timev>:310:in `initialize': invalid value for Integer(): "2023-03-23" (ArgumentError)
	from ./tools/modules/committer_count.rb:47:in `new'
	from ./tools/modules/committer_count.rb:47:in `parse_date'
	from ./tools/modules/committer_count.rb:52:in `<main>'

After

# ./tools/modules/committer_count.rb | head
Commits since 2005-03-22
--------------------------------------------------
wchen-r7                  6475
hdm                       4688
juanvazquez               4342
William Vu                3610
egypt                     2895
todb-r7                   2848
bcook-r7                  2767
Metasploit Bot            2310
# ./tools/modules/committer_count.rb 2023-03-23 | head
Commits since 2023-03-23
--------------------------------------------------
Jack Heysel                 2
jheysel-r7                  1

@bcoles bcoles added the easy label Mar 28, 2023
@adfoster-r7 adfoster-r7 self-assigned this Mar 28, 2023
@adfoster-r7 adfoster-r7 merged commit f6c4679 into rapid7:master Mar 28, 2023
@adfoster-r7
Copy link
Contributor

Release Notes

Fixes a crash when parsing dates in ./tools/modules/committer_count.rb

@adfoster-r7 adfoster-r7 added the rn-fix release notes fix label Mar 28, 2023
@bcoles bcoles deleted the tools-committer-count branch March 29, 2023 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy rn-fix release notes fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants