mandiant / mandiant/flare-vm

Remove checks code duplication

Open
#727 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:gem: enhancement
Dominant language
PowerShell
Stars
9.1k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Details

The checks code used in the GUI and the command line has a lot of duplication that difficult maintenance as well as keeping the code between both views consistent. One option to remove the code duplication is to have a checks array with an entry per check with the following information and use it in both views:
`(name, info, function, allow_continue)`

For example:
``("Valid Powershell version", "PowerShell version >= 5", Test-PSVersion, False)``

For example:

```PS
function Check-PowerShell-Version {
$psVersion = $PSVersionTable.PSVersion
if ($psVersion -lt [System.Version]"5.0.0") {
return "You are using PowerShell version $psVersion. This is an old version and it is not supported"
}
}
```

This requires displaying the checks in the UI dynamically, by calculating the offsets instead of hardcoding them. This has the advantage that allows to modify this view more easily.

I have proposed this in both https://github.com/mandiant/flare-vm/issues/509 and https://github.com/mandiant/flare-vm/pull/707 but @sara-rn decided not to implement it. Creating the issue so that we have it tracked and can be implemented at a later point.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the duplicated checks used by the GUI and command line, then compare how each view currently renders them. Define the shared checks representation and dynamic UI offsets; the work is done when both views consume the same check definitions without hardcoded duplicated logic.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.