-
Notifications
You must be signed in to change notification settings - Fork 23
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
Engine work #61
base: master
Are you sure you want to change the base?
Engine work #61
Conversation
- Better use of MemoryMarshal - Replaces some home-brew functionality with new dotnet 7 equivalent - Fixed a few sonar warnings - Added [SkipLocalsInit] where appropriate - Updated dependencies: - Microsoft.Extensions.ObjectPool 6.0.10 -> 7.0.0 - ZString 2.4.4 -> 2.5.0 - DryIoc 5.2.2 -> 5.3.1 - Microsoft.Extensions.Caching.Memory 6.0.1 -> 7.0.0 - Microsoft.Extensions.Configuration 6.0.1 -> 7.0.0 - Microsoft.Extensions.Configuration.EnvironmentVariables 6.0.1 -> 7.0.0 - Microsoft.Extensions.Configuration.Json 6.0.0 -> 7.0.0
- Added some more helper functions to IPosition - Fixed a UCI bug with options in regards to bool values - Updated dependencies - Added some static Create() factory methods to Score - Updated SearchParameters slightly - Minor update to HashTable<T> - Clarified some methods in KpkBitBase
- Renamed some TT related stuff - Fixed minor issue with Player ToString(....) - Added Position.Set() tests for code - to be used with endgame setup
- ExtMove -> ValMove - Added RootMove to act as easy use of list of moves - IPieceValue -> IValues - PieceValues -> DefaultPieceValues - Move struct now readonly
- Added AddChessLib() IServiceCollection extension - More types are now more friendly towards IoC in general - Any other developmental changes can be observed through the unit tests - Improved use of PolyglotBook, Blockage - Added IOptions usage for TT - Added PolyglotBook injectable factory with IOptions injected for base path - Perft tests that takes a long time is now disabled in debug mode - Perft time improved.. from ~3.2-3.4 seconds to ~3.0 seconds for start pos d=6 - Updated WebApi demo app
- Fixed a few nullable things - Corrected a few var names
- TT can now be created with 0 size if it is not needed
- Player -> Color (to eliminate confusing semantics) - Added CPM - Update PGN parsing - Add PieceType type - Add CastleSide type - Fix a couple of variable namings - Added a zobrist hash test - Expanded HashKey a bit to be more flexible
|
||
public IEnumerable<string> GenerateMoves(MoveQuery parameters) | ||
{ | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, parameters.Types, parameters.Mode); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to sanitize the parameters.Fen
input before logging it. This can be done by removing any new line characters from the input to prevent log forging. We can use the String.Replace
method to achieve this. The best way to fix the problem without changing existing functionality is to modify the logging statement to sanitize the parameters.Fen
input.
-
Copy modified lines R12-R13
@@ -11,3 +11,4 @@ | ||
{ | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, parameters.Types, parameters.Mode); | ||
var sanitizedFen = parameters.Fen.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", sanitizedFen, parameters.Types, parameters.Mode); | ||
|
|
||
public IEnumerable<string> GenerateMoves(MoveQuery parameters) | ||
{ | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, parameters.Types, parameters.Mode); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to sanitize the user input before logging it. Specifically, we should remove any new line characters from the user input to prevent log forging. This can be done using the String.Replace
method to replace new line characters with an empty string. We will apply this sanitization to the parameters.Types
before it is logged.
-
Copy modified lines R12-R13
@@ -11,3 +11,4 @@ | ||
{ | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, parameters.Types, parameters.Mode); | ||
var sanitizedTypes = parameters.Types.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, sanitizedTypes, parameters.Mode); | ||
|
|
||
public IEnumerable<string> GenerateMoves(MoveQuery parameters) | ||
{ | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, parameters.Types, parameters.Mode); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to sanitize the user input before logging it. Since the log entries are plain text, we should remove any new line characters from the user input to prevent log forging. This can be done using the String.Replace
method to replace new line characters with an empty string.
We will modify the GenerateMoves
method in the MoveGeneratorService
class to sanitize the parameters.Fen
, parameters.Types
, and parameters.Mode
before logging them.
-
Copy modified lines R12-R15
@@ -11,3 +11,6 @@ | ||
{ | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", parameters.Fen, parameters.Types, parameters.Mode); | ||
var sanitizedFen = parameters.Fen.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
var sanitizedTypes = parameters.Types.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
var sanitizedMode = parameters.Mode.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
_logger.LogInformation("Generating moves. fen={Fen},type={Type},mode={Mode}", sanitizedFen, sanitizedTypes, sanitizedMode); | ||
|
Stabilization towards better support for creating a chess engine with ChessLib