Commit graph

349 commits

Author SHA1 Message Date
c5caab0066
Add tests for HasBeenPwned function
Introduced unit tests for the HasBeenPwned function in the hibp_test.go file. These tests consist of scenarios with both secured and compromised passwords, improving the function's reliability and error handling capabilities.
2024-03-12 19:09:51 +01:00
87f93ddbc6
Add HIBP password check functionality
Implemented HIBP password check feature which will crosscheck generated passwords with the HIBP pwned passwords database. This functionality enhances security by not recommending potentially compromised passwords. A new flag, CheckHIBP has been added to enable or disable this feature.
2024-03-12 19:00:21 +01:00
4b0437d3b1
Add pronunciation tests in spelling_test.go
Added "TestPronounce" function in spelling_test.go file to ensure pronunciation mechanism works as expected. The function tests various cases including no syllables, single syllable, multiple syllables, and non-Koremutake syllables.
2024-03-12 18:43:51 +01:00
fefb2557fc
Refactor spelling of "Pronounceable" and introduce syllable spelling feature
The spelling of "Pronounceable" has been adjusted throughout the code. Moreover, a new functionality for producing pronounceable passwords spelled as correlating syllables has been integrated. This includes relevant changes to password character sets used for pronounceable passwords and enhancements to test this new feature.
2024-03-12 18:28:01 +01:00
90ff88de41
Implement additional tests for password generation functionality
In this commit, several new tests have been introduced into random_test.go. These include cases for generating pronounceable passwords, testing minimum requirement conditions, and checking different password algorithms. This provides more comprehensive testing coverage and confirms the expected functionality of password generator methods.
2024-03-12 17:49:26 +01:00
8cb702c932
Add password length and coin flip tests in random_test.go
Added detailed test cases for handling password length and coin flip functionality in random_test.go. These additional unit tests cover various conditions for password lengths, and ensure that 'generateCoinFlip' behaves as expected across multiple invocations.
2024-03-12 16:57:48 +01:00
2973ff4c39
Remove unnecessary comments in random_test.go
Removed redundant comments in random_test.go, specifically in TestGetCharRangeFromConfig function. This change simplifies and tidies the code, while maintaining its comprehensibility and the clarity of the test cases structure.
2024-03-12 16:43:20 +01:00
a03f170738
Add TestSpell function in spelling_test.go
Added a new unit test, TestSpell, to the spelling_test.go file. This new test safely triggers several different spell checking scenarios, from empty strings to non-alphabetical characters. As a result, the function's reliability and robustness is significantly improved.
2024-03-12 12:14:46 +01:00
45b45919c1
Add TestGetCharRangeFromConfig function in random_test.go
A comprehensive unit test, TestGetCharRangeFromConfig, has been added to the random_test.go file. This test validates the GetCharRangeFromConfig function across various scenarios and configurations. It also improves code reliability and makes the application more robust against potential issues.
2024-03-12 12:14:36 +01:00
1c22c9b8f0
Refactor error message in mode_test.go
The error message format in `ModesFromFlags()` method within `mode_test.go` has been refactored. The refactoring improved the clarity and conciseness of error reporting when the expected mode is not found during test execution.
2024-03-08 17:08:05 +01:00
72576961e6
Implement pronouncable password generation and refactor code
The new function "generatePronouncable" generates pronounceable passwords using the Koremutake syllabic representation. It is executed when 'Generate()' method is called with Algorithm set to 'AlgoPronouncable'. Additionally, significant changes were made to enhance the readability and performance of the 'GetCharRangeFromConfig' and 'checkMinimumRequirements' methods. In 'mode_test.go', the error message format has been updated for clear and concise display.
2024-03-08 17:07:55 +01:00
bd654d40b8
Refactor error messages in spelling tests
Modified the error messages in spelling tests within spelling_test.go to improve clarity and readability. These adjustments involve changing the format specifiers in the error messages of 'ConvertByteToWord' function tests to correspond with the expected data types for better error reporting.
2024-03-08 16:04:16 +01:00
93f092e690
Add phonetic spelling functionality to password generator
The update introduces a new 'SpellPassword' setting in the configuration that, when enabled, spells out the generated passwords in the phonetic alphabet. The accompanied changes include the addition of 'spelling.go' and 'spelling_test.go' files containing the spelling logic and corresponding tests. The domain-specific error handling is also enhanced for unsupported characters.
2024-03-08 16:03:02 +01:00
4219a27007
Refactor variable names and improve code readability in apg.go
Updated several variable names such as 'c' to 'config' and 'al' to 'algorithm' in order to improve code readability and understanding. An additional 'SpellPassword' option was added to provide users the ability to hear their passwords spelled out, enhancing functionality. This improves readability and user experience.
2024-03-08 16:02:32 +01:00
0ad5f4a74d
Refactor variable names in random.go
Updated variable naming within the CoinFlip function to enhance clarity. Also added an additional case statement within the Generate function for the 'AlgoPronouncable' algorithm. These changes improve readability and extend the functionality of the random number generation code.
2024-03-08 10:22:34 +01:00
b6f91459c5
Refactor variable names in mode.go
Renamed variables in the MaskSetMode, MaskClearMode, MaskToggleMode, and MaskHasMode functions as well as within ModesFromFlags function to improve clarity and readability of their functionality. These changes ensure that the purpose of each variable is immediately identifiable, enhancing maintainability of the codebase.
2024-03-08 10:22:20 +01:00
61ca9af22a
Refactor Generator struct and New function in apg.go
Removed the unused 'charRange' field from the Generator struct. Also, renamed the parameter in the New function from 'c' to 'config' for better clarity and understanding of its purpose.
2024-03-08 10:21:57 +01:00
e17da1a2c9
Improve code readability by refactoring variable names
Several variable names have been changed in 'random.go' to improve overall readability and code comprehension. Additionally, a typo was fixed and a new constant was introduced for the maximum value of Int32, to replace previously hard-coded values. The adjustments not only make the code more digestible, but also adhere to good coding practices.
2024-03-07 23:22:28 +01:00
8f8e439f56
Refactor variable names and correct typos in RandomBytes and RandNum methods
This commit includes refactoring variable names to enhance readability and understanding within the `RandomBytes`, `RandNum` and `RandomStringFromCharRange` methods. A constant, `maxInt32`, was also added to replace a hard-coded value for better code practice. Typos in the comments and documentation were corrected as well.
2024-03-07 22:50:47 +01:00
4b874e499e
Fix typos in 'implies' within command-line flags description
The previous version misspelled 'implies' as 'imlies' for several command-line flags (-mN, -mS, -mU) in the apg.go file. This commit corrects these typos, ensuring clarity and better understanding of the program's functions and usage.
2024-03-07 21:51:52 +01:00
b2d6a3418e
Add Codecov, SonarQube, REUSE Compliance, and golangci-lint workflows
The commit includes the addition of four new workflows to the .forgejo workflows directory. These are Codecov for code coverage handling, SonarQube for continuous inspection of code quality, REUSE Compliance Check for license compliance, and golangci-lint for running linters on Go code. The workflows all target the 'main' branch and are triggered by 'push' and 'pull_request' events.
2024-03-07 21:36:57 +01:00
c3eb80a183
Correct "Number" to "Numeric" in mode_test.go
The string representation for the "ModeNumeric" enumeration member was incorrectly labeled as "Number". This has been corrected to "Numeric" in the mode tests file mode_test.go to maintain correct and consistent naming conventions.
2024-03-07 21:22:24 +01:00
03867adac0
Replace AlgoUnsupported with AlgoCoinflip in algo_test.go
The previously named "AlgoUnsupported" has been replaced with "AlgoCoinflip" in the algorithm tests in algo_test.go. Additionally, the "AlgoUnsupported" test has been moved down to keep the test sequence logical and comprehensive.
2024-03-07 21:22:14 +01:00
86ca627fed
Add password generation algorithm option and corresponding tests
The password generation algorithm is now customizable via the `WithAlgorithm()` function, giving users more control over password generation. Tests have been added to 'config_test.go' to ensure correct functionality of the new option. Additionally, the variable naming in 'config.go' has been improved for better readability.
2024-03-07 21:16:04 +01:00
8dce4d2eb9
Update import path and change copyright year in apg.go
The import path of the module "apg-go" has been changed to "src.neessen.cloud/wneessen/apg-go". Furthermore the copyright year mentioned in the usage text has been updated to 2024.
2024-03-07 21:15:49 +01:00
86b0ca972e
Update go.mod module path and Go version
The go.mod file was updated to reflect a new module path and an upgrade in Go version. The module path is now set to src.neessen.cloud/wneessen/apg-go, and the Go version has been updated to 1.22.
2024-03-07 21:15:36 +01:00
203da17634
#52 and #53: Increase password generation flexibility and error handling
Added code to check if set minimum password requirements are met after generating a random password. If not, the password generation process is repeated.
This not only adds an extra layer of security but also ensures that all set criteria for the password are met.
Also enhanced error handling in functions that could return a negative integer when asked for a random number.
Changed 'minimum amount of' parameter descriptions in apg.go to avoid confusion.
2023-08-06 18:55:47 +02:00
2822f73f56
#53 Add coinflip algorithm and improve error messages
Introduced a new password generation algorithm, called 'coinflip', which simply returns "Heads" or "Tails". Associated CLI flag has been added as well. Also, improved error messages during password generation. This addition provides a simpler algorithm option and clearer user feedback during errors.
2023-08-05 18:10:11 +02:00
8d42651e58
#53 Update password configuration parameters
Added comments for minimum requirements parameters in config.go to provide clarity on their purpose. This was necessary to increase code readability, making it easier for future developer reference.
2023-08-05 17:57:06 +02:00
af6d87c1a3
#53 and #52: Update "Number" references to "Numeric" in password generator
Replaced all instances of "Number" with "Numeric" in the password
generator. This modification will make the password generation code
more intuitive and readable. Moreover, minimum character requirements
were added for each character type, giving more flexibility to the
password generation settings.
2023-08-05 17:54:41 +02:00
d28b0645fd
#53 Update CLI usage message in apg.go
The usage message has been updated in apg.go to improve its clarity and usefulness. Changes include displaying the version number dynamically, providing the project's GitHub link, changing the term 'options' to 'flags', and more precise terminology in descriptions. Also, formatting has been adjusted to improve readability.
2023-08-05 15:14:43 +02:00
499a82d884
#53 Add fixed length option for password generation
A FixedLength field was added to the Config struct and a corresponding command line flag was added in `apg.go`. The field allows for the generation of passwords of a fixed length, overriding the MinLength and MaxLength values if present. Revised the `random.go` script to accommodate this change. The option for fixed length enhances the flexibility and customization of the password generation tool.
2023-08-05 15:04:34 +02:00
1e1ae45e74
#53 Refactor password generator to include additional modes
Updated the password generator to include default modes for characters along with options to enable complex password mode and toggle specific character types in passwords from the command line. This allows for greater customization and more user control in password generation, especially useful for applications with unique password requirements."
2023-08-05 14:47:30 +02:00
69bb1e4cb7
#53 Add tests and refactor Algorithm constants
Test suite `TestIntToAlgo` was added to `algo_test.go` to validate `IntToAlgo` function. Additionally, Algorithm constants in `algo.go` have been prefixed with "Algo". These changes were made in order to make the code clearer and ensure the function returns the expected values for the given inputs.
2023-08-04 20:35:31 +02:00
3cccc65498
#53 Add ModeHumanReadable and refactor mode tests
Updated mode tests to include a new Mode, ModeHumanReadable, and created an additional test case, ModeComplexNoHumanReadable. This was done because a more human readable mode was required for some use cases. Also added a test function TestMode_String to ensure the .String() method of each mode works as intended.
2023-08-04 20:29:43 +02:00
f3a4b516d1
Reorder modes and add new test for modes
The ordering of modes in the existing test was changed to logically group them together. In addition, a new test was added, `TestModesFromFlags`, to cover multiple different conditions including complex modes and cases where certain mode elements are excluded. This expansion in testing enhances our coverage of varied mode settings.
2023-08-04 18:38:55 +02:00
704269d0b8
#53 Reorder modes and add new test case for mode flags
This commit primarily reorders the modes in the "mode_test.go" file for consistency. The order is now; ModeHumanReadable, ModeLowerCase, ModeNumber, ModeSpecial, ModeUpperCase. This now follows a logical order instead of the previous semi arbitrary one.

The commit also involves the addition of a new test case 'TestModesFromFlags' in the "mode_test.go" file. This test case aims at increasing the code coverage and ensuring modes obtained from the flags are correct.

Lastly, the 'ModesFromFlags' function in the "mode.go" has been slightly refactored for improved readability. This does not change the functionality and thus won't affect the rest of the codebase.
2023-08-04 18:38:32 +02:00
b31219046a
#53 Refactor mode handling and bitmask functions
The naming and handling of mode bitmasks have been refactored for improved code readability and maintainability. The term "Mode" was replaced with "ModeMask" for clarity and all associated functions were renamed accordingly (e.g., "SetMode" to "MaskSetMode"). These changes provide better insight into the function of the code and increase understandability for future development efforts. The command-line utility now also supports specifying modes via the "-M" flag.
2023-08-04 17:14:24 +02:00
ac97b94ec9
Refactor generator and add config options
Refactored the generator to include a new config option, changed function signatures to follow the new structure, and renamed the function 'RandomString' to 'RandomStringFromCharRange' for clarity. Also, added a new mode and algorithm feature to enhance password generation. Furthermore, added several tests for new features and configurations. Adapted the CLI to use the new configuration approach. This refactoring was necessary to improve the customizability and clarity of the password generation process. Fixed minor issues and added '.gitignore' for clean commits in the future.
2023-08-04 16:02:58 +02:00
e94b1ade5c
v2: Complete rework of the library and the client 2023-04-18 11:49:44 +02:00
2975dfea51
Remove old code for the v2 refactor 2023-04-06 12:23:22 +02:00
befa6c2723
Remove old code for the v2 refactor 2023-04-06 12:21:20 +02:00
565a714cc6
Merge pull request #51 from wneessen/dependabot/go_modules/github.com/wneessen/go-hibp-1.0.6
Bump github.com/wneessen/go-hibp from 1.0.5 to 1.0.6
2023-02-09 21:09:54 +01:00
dependabot[bot]
8d6dc64cc4
Bump github.com/wneessen/go-hibp from 1.0.5 to 1.0.6
Bumps [github.com/wneessen/go-hibp](https://github.com/wneessen/go-hibp) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/wneessen/go-hibp/releases)
- [Commits](https://github.com/wneessen/go-hibp/compare/v1.0.5...v1.0.6)

---
updated-dependencies:
- dependency-name: github.com/wneessen/go-hibp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 19:58:17 +00:00
149c4eb54c
Merge pull request #50 from wneessen/dependabot/go_modules/github.com/wneessen/go-hibp-1.0.5
Bump github.com/wneessen/go-hibp from 1.0.4 to 1.0.5
2022-12-22 20:27:37 +01:00
dependabot[bot]
bf2c303ca5
Bump github.com/wneessen/go-hibp from 1.0.4 to 1.0.5
Bumps [github.com/wneessen/go-hibp](https://github.com/wneessen/go-hibp) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/wneessen/go-hibp/releases)
- [Commits](https://github.com/wneessen/go-hibp/compare/v1.0.4...v1.0.5)

---
updated-dependencies:
- dependency-name: github.com/wneessen/go-hibp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-22 19:04:28 +00:00
a08b362e19
Merge pull request #49 from wneessen/go-hibp-update
Upgrade go-hibp to v1.0.4 and fix the breaking changes
2022-10-29 20:44:22 +02:00
beb01894cd
Upgrade go-hibp to v1.0.4 and fix the breaking changes 2022-10-29 20:43:22 +02:00
359bd791b4
Merge pull request #48 from wneessen/dependabot/go_modules/github.com/wneessen/go-hibp-1.0.3
Bump github.com/wneessen/go-hibp from 1.0.2 to 1.0.3
2022-06-10 22:25:16 +02:00
dependabot[bot]
58c20de5cf
Bump github.com/wneessen/go-hibp from 1.0.2 to 1.0.3
Bumps [github.com/wneessen/go-hibp](https://github.com/wneessen/go-hibp) from 1.0.2 to 1.0.3.
- [Release notes](https://github.com/wneessen/go-hibp/releases)
- [Commits](https://github.com/wneessen/go-hibp/compare/v1.0.2...v1.0.3)

---
updated-dependencies:
- dependency-name: github.com/wneessen/go-hibp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-10 19:22:26 +00:00