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

add pass-station #3050

Merged
merged 2 commits into from
Mar 17, 2021
Merged

add pass-station #3050

merged 2 commits into from
Mar 17, 2021

Conversation

noraj
Copy link
Contributor

@noraj noraj commented Mar 15, 2021

No description provided.

@noraj noraj added lang::ruby status::pending-review A PR was linked to the issue and is waiting review before being merged and the issue closed. labels Mar 15, 2021
Copy link
Contributor

@Edu4rdSHL Edu4rdSHL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm getting this error while testing:

┌─[ ArchDevel /tmp/tmp.NPP1nyApMq ]
└──╼ $ ba-dev -p pass-station-v1.1.0.r0.g2ba48f6-1-any.pkg.tar.zst -e "pass-station list"
loading packages...
warning: pass-station-v1.1.0.r0.g2ba48f6-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) pass-station-v1.1.0.r0.g2ba48f6-1

Total Installed Size:  0.10 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                                     [####################################################################] 100%
(1/1) checking package integrity                                                                                   [####################################################################] 100%
(1/1) loading package files                                                                                        [####################################################################] 100%
(1/1) checking for file conflicts                                                                                  [####################################################################] 100%
(1/1) checking available disk space                                                                                [####################################################################] 100%
:: Processing package changes...
(1/1) reinstalling pass-station                                                                                    [####################################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
Package pass-station-v1.1.0.r0.g2ba48f6-1-any.pkg.tar.zst installed correctly! Testing it now...
Traceback (most recent call last):
	5: from /usr/bin/pass-station:23:in `<main>'
	4: from /usr/bin/pass-station:23:in `load'
	3: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/bin/pass-station:67:in `<top (required)>'
	2: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/bin/pass-station:67:in `new'
	1: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/lib/pass_station.rb:34:in `initialize'
/usr/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/lib/pass_station.rb:45:in `database_exists?': Database does not exist: data/DefaultCreds-Cheat-Sheet.csv (RuntimeError)

Maybe a postinstall is required to setup the database?

Regards, Ed.

@noraj
Copy link
Contributor Author

noraj commented Mar 16, 2021

$ tree /home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/                                   
/home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/
├── bin
│   ├── pass-station
│   └── pass-station_console
├── data
│   └── DefaultCreds-Cheat-Sheet.csv
├── lib
│   ├── pass_station
│   │   ├── output.rb
│   │   ├── parse.rb
│   │   ├── search.rb
│   │   ├── source.rb
│   │   └── version.rb
│   └── pass_station.rb
└── LICENSE

4 directories, 10 files

The database is in the gem this is a path issue, it works only from the root install dir:

$ ➜ pass-station list
Traceback (most recent call last):
        5: from /home/noraj/.asdf/installs/ruby/2.7.2/bin/pass-station:23:in `<main>'
        4: from /home/noraj/.asdf/installs/ruby/2.7.2/bin/pass-station:23:in `load'
        3: from /home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/bin/pass-station:67:in `<top (required)>'
        2: from /home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/bin/pass-station:67:in `new'
        1: from /home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/lib/pass_station.rb:34:in `initialize'
/home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/lib/pass_station.rb:45:in `database_exists?': Database does not exist: data/DefaultCreds-Cheat-Sheet.csv (RuntimeError)

➜ cd /home/noraj/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pass-station-1.1.0/
➜ pass-station list 
+------------------------------------------------------+----------------------------+-----------------------------------------------------------------+
| productvendor                                        | username                   | password                                                        |
+------------------------------------------------------+----------------------------+-----------------------------------------------------------------+
| 2wire (ssh)                                          | admin                      | admin                                                           | 
| 2Wire,Inc.                                           | http                       | <blank>                                                         | 
| 360 Systems                                          | factory                    | factory                                                         | 
| 3COM                                                 | 3comcso                    | RIP000                                                          | 
| 3COM                                                 | adm                        | <blank>                                                         | 
| 3COM                                                 | admin                      | 1234admin                                                       | 
| 3COM                                                 | admin                      | admin                                                           | 

I have to fix this method:

    # Check if the password database exists
    # @return [Boolean] +true+ if the file exists
    def database_exists?
      exists = File.file?(@database_path)
      raise "Database does not exist: #{@database_path}" unless exists

      exists
    end

It's 100% bad code from me, nothing to change on the PKGBUILD.

@noraj
Copy link
Contributor Author

noraj commented Mar 16, 2021

@Edu4rdSHL
Copy link
Contributor

Hey @noraj, thank you but I'm now getting this error while executing list/search:

┌─[ ArchDevel /tmp/tmp.NPP1nyApMq ]
└──╼ $ ba-dev -p pass-station-v1.2.0.r0.g487f224-1-any.pkg.tar.zst -e "pass-station list"
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) pass-station-v1.2.0.r0.g487f224-1

Total Installed Size:  0.11 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                     [######################] 100%
(1/1) checking package integrity                   [######################] 100%
(1/1) loading package files                        [######################] 100%
(1/1) checking for file conflicts                  [######################] 100%
(1/1) checking available disk space                [######################] 100%
:: Processing package changes...
(1/1) installing pass-station                      [######################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
Package pass-station-v1.2.0.r0.g487f224-1-any.pkg.tar.zst installed correctly! Testing it now...
Traceback (most recent call last):
	22: from /usr/bin/pass-station:23:in `<main>'
	21: from /usr/bin/pass-station:23:in `load'
	20: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.2.0/bin/pass-station:68:in `<top (required)>'
	19: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.2.0/lib/pass_station/parse.rb:29:in `parse'
	18: from /usr/lib/ruby/2.7.0/csv.rb:737:in `table'
	17: from /usr/lib/ruby/2.7.0/csv.rb:715:in `read'
	16: from /usr/lib/ruby/2.7.0/csv.rb:658:in `open'
	15: from /usr/lib/ruby/2.7.0/csv.rb:715:in `block in read'
	14: from /usr/lib/ruby/2.7.0/csv.rb:1289:in `read'
	13: from /usr/lib/ruby/2.7.0/csv.rb:1289:in `to_a'
	12: from /usr/lib/ruby/2.7.0/csv.rb:1280:in `each'
	11: from /usr/lib/ruby/2.7.0/csv.rb:1280:in `each'
	10: from /usr/lib/ruby/2.7.0/csv/parser.rb:336:in `parse'
	 9: from /usr/lib/ruby/2.7.0/csv/parser.rb:823:in `parse_quotable_loose'
	 8: from /usr/lib/ruby/2.7.0/csv/parser.rb:103:in `each_line'
	 7: from /usr/lib/ruby/2.7.0/csv/parser.rb:103:in `each_line'
	 6: from /usr/lib/ruby/2.7.0/csv/parser.rb:127:in `block in each_line'
	 5: from /usr/lib/ruby/2.7.0/csv/parser.rb:862:in `block in parse_quotable_loose'
	 4: from /usr/lib/ruby/2.7.0/csv/parser.rb:884:in `parse_quotable_robust'
	 3: from /usr/lib/ruby/2.7.0/csv/parser.rb:960:in `parse_column_value'
	 2: from /usr/lib/ruby/2.7.0/csv/parser.rb:968:in `parse_unquoted_column_value'
	 1: from /usr/lib/ruby/2.7.0/csv/parser.rb:157:in `scan_all'
/usr/lib/ruby/2.7.0/csv/parser.rb:237:in `read_chunk': CSV::Parser::InvalidEncoding (CSV::Parser::InvalidEncoding)
	13: from /usr/bin/pass-station:23:in `<main>'
	12: from /usr/bin/pass-station:23:in `load'
	11: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.2.0/bin/pass-station:68:in `<top (required)>'
	10: from /usr/lib/ruby/gems/2.7.0/gems/pass-station-1.2.0/lib/pass_station/parse.rb:29:in `parse'
	 9: from /usr/lib/ruby/2.7.0/csv.rb:737:in `table'
	 8: from /usr/lib/ruby/2.7.0/csv.rb:715:in `read'
	 7: from /usr/lib/ruby/2.7.0/csv.rb:658:in `open'
	 6: from /usr/lib/ruby/2.7.0/csv.rb:715:in `block in read'
	 5: from /usr/lib/ruby/2.7.0/csv.rb:1289:in `read'
	 4: from /usr/lib/ruby/2.7.0/csv.rb:1289:in `to_a'
	 3: from /usr/lib/ruby/2.7.0/csv.rb:1280:in `each'
	 2: from /usr/lib/ruby/2.7.0/csv.rb:1280:in `each'
	 1: from /usr/lib/ruby/2.7.0/csv/parser.rb:329:in `parse'
/usr/lib/ruby/2.7.0/csv/parser.rb:346:in `rescue in parse': Invalid byte sequence in US-ASCII in line 2934. (CSV::MalformedCSVError)

Can you please check?

@noraj noraj self-assigned this Mar 16, 2021
@noraj
Copy link
Contributor Author

noraj commented Mar 17, 2021

I'm not really sure what is causing the encoding issue.

  • ✅ local test ruby -Ilib -rpass_station bin/pass-station list
  • ✅ gem test gem install pass-station + pass-station list
  • ba-dev -e 'pass-station list' -p pass-station-v1.2.0.r0.g487f224-1-any.pkg.tar.zst

So this time it does not come from the code but encoding inside the PKGBUILD. And I don't see any specific character that could cause an issue at https://github.com/sec-it/pass-station/blob/master/data/DefaultCreds-Cheat-Sheet.csv#L2934

@noraj
Copy link
Contributor Author

noraj commented Mar 17, 2021

On my machine

$ env | grep -E 'LANG|LC'                                                                                                                                                                                                          master ✔
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ADDRESS=fr_FR.UTF-8
LC_COLLATE=fr_FR.UTF-8
LC_CTYPE=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8

But there is no encoding define on the ba-dev build environment, not even LANG that's why it's failing @Edu4rdSHL

Try to prefix with an UTF8 env var and it goes well and smooth.

$ ba-dev -e 'LANG=en_US.UTF-8 pass-station list' -p pass-station-v1.2.0.r0.g487f224-1-any.pkg.tar.zst

Copy link
Contributor

@Edu4rdSHL Edu4rdSHL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @noraj, I've tested and it works fine, thank you.

@Edu4rdSHL Edu4rdSHL merged commit a58dbce into master Mar 17, 2021
@noraj noraj deleted the pass-station branch March 17, 2021 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang::ruby status::pending-review A PR was linked to the issue and is waiting review before being merged and the issue closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants