[Bug] When there are many tasks, smb grunt cannot connect normally
- Dominant language
- C#
- Stars
- 4.7k
- Forks
- 822
- PR merge metrics
- No merged PRs in 30d
Description
**Feature Request or Bug**
Bug
**Describe the feature request or bug**
Because of the lack of efficient data query, Memory limitation caused smb grunt cannot be connected normally.
Code location:
https://github.com/cobbr/Covenant/blob/f831778e836f49b5817c1a847d404f708b96b1ad/Covenant/Models/Listeners/InternalListener.cs#L648
The following exception may be thrown:
`Cannot write more bytes to the buffer than the configured maximum buffer size: 2147483647.`
It should be noted that this exception is only when I try {} catch {} the line of code, otherwise it will be caught by the upper layer and eventually become 404 not found.
**To Reproduce**
Steps to reproduce the behavior:
1. Generate too much tasks...
2. Using HTTP grunt to connect SMB grunt
**Expected behavior**
Only fetch egress grunt tasks
**Covenant Server Information:**
- OS: Ubuntu20.04
- Docker or Native: Native
**Additional context**
This problem may cause smb grunt to fail to connect, so https://github.com/cobbr/Covenant/issues/224 may also be caused by this problem; in addition to this, it is also recommended that other places take more efficient methods, namely Get only the data you need into the memory.
After modifying the code to these, smb grunt successfully connected:
```csharp
if (egressGrunt.Id.HasValue)
taskings = _client.GetGruntTaskings(egressGrunt.Id.Value).ToList();
else
taskings = _client.GetAllGruntTaskings().ToList();
```
I am not good at csharp and familiar with this project, so the code is for reference only : ).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.