-
Notifications
You must be signed in to change notification settings - Fork 23
Main #90
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
Merged
Merged
Main #90
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cfba194
Add command implementations for network and system utilities
smirk-dev 1b056d2
Remove unused import for StringUtils in App.java and update package d…
smirk-dev 207d805
Merge upstream: resolved TimeoutCommand conflict, kept robust impleme…
smirk-dev 66aee71
Add Spotless Maven plugin to fix formatter workflow
smirk-dev 5b02149
Add VSCode settings for Java build configuration
smirk-dev ee29e87
Apply Spotless formatting
github-actions[bot] 72bfffc
Merge remote-tracking branch 'upstream/main'
smirk-dev 47c4c7a
Merge: Resolved ShellContext.java conflict - removed duplicate envVar…
smirk-dev bb6ad41
Apply Spotless formatting
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package com.mycmd.utils; | ||
| package com.mycmd; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Objects; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package com.mycmd.commands; | ||
|
|
||
| import com.mycmd.Command; | ||
| import com.mycmd.ShellContext; | ||
|
|
||
| import java.io.BufferedReader; | ||
| import java.io.IOException; | ||
| import java.io.InputStreamReader; | ||
|
|
||
| /** | ||
| * Displays and modifies the IP-to-Physical address translation tables (ARP cache). | ||
| * | ||
| * Usage: | ||
| * - arp -a : Display ARP cache | ||
| */ | ||
| public class ArpCommand implements Command { | ||
|
|
||
| @Override | ||
| public void execute(String[] args, ShellContext context) throws IOException { | ||
| try { | ||
| StringBuilder cmdBuilder = new StringBuilder("arp"); | ||
| for (String arg : args) { | ||
| cmdBuilder.append(" ").append(arg); | ||
| } | ||
|
|
||
| // Default to -a if no args provided | ||
| if (args.length == 0) { | ||
| cmdBuilder.append(" -a"); | ||
| } | ||
|
|
||
| ProcessBuilder pb = new ProcessBuilder(); | ||
| String os = System.getProperty("os.name").toLowerCase(); | ||
|
|
||
| if (os.contains("win")) { | ||
| pb.command("cmd.exe", "/c", cmdBuilder.toString()); | ||
| } else { | ||
| pb.command("sh", "-c", cmdBuilder.toString()); | ||
| } | ||
|
|
||
| Process process = pb.start(); | ||
| BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | ||
| BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); | ||
|
|
||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| System.out.println(line); | ||
| } | ||
|
|
||
| while ((line = errorReader.readLine()) != null) { | ||
| System.err.println(line); | ||
| } | ||
|
|
||
| process.waitFor(); | ||
|
|
||
| } catch (Exception e) { | ||
| System.out.println("Error executing arp: " + e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String description() { | ||
| return "Displays and modifies the IP-to-Physical address translation tables."; | ||
| } | ||
|
|
||
| @Override | ||
| public String usage() { | ||
| return "arp [-a] [-d ip_addr] [-s ip_addr eth_addr]"; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden ARP execution: no shell string, no deadlocks; add timeout + cwd.
Apply:
Also applies to: 20-57
🤖 Prompt for AI Agents