Package ghidra.framework.protocol.ghidra
Class GhidraURL
java.lang.Object
ghidra.framework.protocol.ghidra.GhidraURL
Supported URL forms include:
- ghidra://<host>:<port>/<repository-name>[/<folder-path>]/[<folderItemName>[#ref]]
- ghidra:/[X:/]<project-path>/<project-name>[?[/<folder-path>]/[<folderItemName>[#ref]]]
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDisplayString(URL url) Generate preferred display string for Ghidra URLs.static URLgetNormalizedURL(URL url) Get a normalized URL which eliminates use of host names and optional URL ref which may prevent direct comparison.static StringgetProjectPathname(URL ghidraUrl) Get the project pathname referenced by the specified Ghidra file/folder URL.static ProjectLocatorgetProjectStorageLocator(URL localProjectURL) Get the project locator which corresponds to the specified local project URL.static URLgetProjectURL(URL ghidraUrl) Get normalized URL which corresponds to the local-project or repositorystatic StringgetRepositoryName(URL url) Get the shared repository name associated with a repository URL or null if not applicable.static booleanisGhidraURL(String str) Determine if the specified string appears to be a possible ghidra URL (starts with "ghidra:/").static booleanisGhidraURL(URL url) Tests if the given url is using the Ghidra protocolstatic booleanisLocalGhidraURL(String str) Determine if URL string uses a local format (e.g.,ghidra:/path...).static booleanisLocalProjectURL(URL url) Determine if the specified URL is a local project URL.static booleanisServerRepositoryURL(URL url) Determine if the specified URL is any type of server "repository" URL.static booleanisServerURL(String str) Determine if URL string uses a remote server format (e.g.,ghidra://host...).static booleanisServerURL(URL url) Determine if the specified URL is any type of supported server Ghidra URL.static booleanlocalProjectExists(URL url) Determine if the specified URL refers to a local project and it exists.static URLmakeURL(ProjectLocator projectLocator) Create a URL which refers to a local Ghidra projectstatic URLmakeURL(ProjectLocator projectLocator, String projectFilePath, String ref) Create a URL which refers to a local Ghidra project with optional project file and refstatic URLCreate a URL which refers to Ghidra Server repository and its root folderstatic URLCreate a URL which refers to Ghidra Server repository content.static URLCreate a URL which refers to Ghidra Server repository content.static URLmakeURL(String host, int port, String repositoryName, String repositoryFolderPath, String fileName, String ref) Create a URL which refers to Ghidra Server repository content.static URLCreate a URL which refers to a local Ghidra projectstatic URLCreate a URL which refers to a local Ghidra project with optional project file and refstatic URLCreate a Ghidra URL from a string form of Ghidra URL or local project path.
-
Field Details
-
PROTOCOL
- See Also:
-
MARKER_FILE_EXTENSION
- See Also:
-
PROJECT_DIRECTORY_EXTENSION
- See Also:
-
-
Method Details
-
localProjectExists
Determine if the specified URL refers to a local project and it exists.- Parameters:
url- ghidra URL- Returns:
- true if specified URL refers to a local project and it exists.
-
isGhidraURL
Determine if the specified string appears to be a possible ghidra URL (starts with "ghidra:/").- Parameters:
str- string to be checked- Returns:
- true if string is possible ghidra URL
-
isGhidraURL
Tests if the given url is using the Ghidra protocol- Parameters:
url- the url to test- Returns:
- true if the url is using the Ghidra protocol
-
isLocalGhidraURL
Determine if URL string uses a local format (e.g.,ghidra:/path...). Extensive validation is not performed. This method is intended to differentiate from a server URL only.- Parameters:
str- URL string- Returns:
- true if string appears to be local Ghidra URL, else false
-
isServerURL
Determine if URL string uses a remote server format (e.g.,ghidra://host...). Extensive validation is not performed. This method is intended to differentiate from a local URL only.- Parameters:
str- URL string- Returns:
- true if string appears to be remote server Ghidra URL, else false
-
isLocalProjectURL
Determine if the specified URL is a local project URL. No checking is performed as to the existence of the project.- Parameters:
url- ghidra URL- Returns:
- true if specified URL refers to a local project (ghidra:/path/projectName...)
-
getProjectStorageLocator
Get the project locator which corresponds to the specified local project URL. Confirm local project URL withisLocalProjectURL(URL)prior to method use.- Parameters:
localProjectURL- local Ghidra project URL- Returns:
- project locator or null if invalid path specified
- Throws:
IllegalArgumentException- URL is not a valid local project URL
-
getRepositoryName
Get the shared repository name associated with a repository URL or null if not applicable. For ghidra URL extensions it is assumed that the first path element corresponds to the repository name.- Parameters:
url- ghidra URL for shared project resource- Returns:
- repository name or null if not applicable to URL
-
isServerRepositoryURL
Determine if the specified URL is any type of server "repository" URL. No checking is performed as to the existence of the server or repository. NOTE: ghidra protocol extensions are not currently supported (e.g., ghidra:http://...).- Parameters:
url- ghidra URL- Returns:
- true if specified URL refers to a Ghidra server repository (ghidra://host/repositoryNAME/path...)
-
isServerURL
Determine if the specified URL is any type of supported server Ghidra URL. No checking is performed as to the existence of the server or repository.- Parameters:
url- ghidra URL- Returns:
- true if specified URL refers to a Ghidra server repository (ghidra://host/repositoryNAME/path...)
-
toURL
Create a Ghidra URL from a string form of Ghidra URL or local project path. This method can consume strings produced by the getDisplayString method.- Parameters:
projectPathOrURL- project path (<absolute-directory>/<project-name>) or string form of Ghidra URL.- Returns:
- local Ghidra project URL
- Throws:
IllegalArgumentException- invalid path or URL specified- See Also:
-
getProjectURL
Get normalized URL which corresponds to the local-project or repository- Parameters:
ghidraUrl- ghidra file/folder URL (server-only URL not permitted)- Returns:
- local-project or repository URL
-
getProjectPathname
Get the project pathname referenced by the specified Ghidra file/folder URL. If path is missing root folder is returned.- Parameters:
ghidraUrl- ghidra file/folder URL (server-only URL not permitted)- Returns:
- pathname of file or folder
-
getNormalizedURL
Get a normalized URL which eliminates use of host names and optional URL ref which may prevent direct comparison.- Parameters:
url- ghidra URL- Returns:
- normalized url
-
getDisplayString
Generate preferred display string for Ghidra URLs. Form can be parsed by the toURL method.- Parameters:
url- ghidra URL- Returns:
- formatted URL display string
- See Also:
-
makeURL
Create a URL which refers to a local Ghidra project- Parameters:
dirPath- absolute path of project location directoryprojectName- name of project- Returns:
- local Ghidra project URL
-
makeURL
Create a URL which refers to a local Ghidra project- Parameters:
projectLocator- absolute project location- Returns:
- local Ghidra project URL
- Throws:
IllegalArgumentException- ifprojectLocatordoes not have an absolute location
-
makeURL
public static URL makeURL(String projectLocation, String projectName, String projectFilePath, String ref) Create a URL which refers to a local Ghidra project with optional project file and ref- Parameters:
projectLocation- absolute path of project location directoryprojectName- name of projectprojectFilePath- file path (e.g., /a/b/c, may be null)ref- location reference (may be null)- Returns:
- local Ghidra project URL
- Throws:
IllegalArgumentException- if an absolute projectLocation path is not specified
-
makeURL
Create a URL which refers to a local Ghidra project with optional project file and ref- Parameters:
projectLocator- local project locatorprojectFilePath- file path (e.g., /a/b/c, may be null)ref- location reference (may be null)- Returns:
- local Ghidra project URL
- Throws:
IllegalArgumentException- if invalidprojectFilePathspecified or if URL instantion fails.
-
makeURL
Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.- Parameters:
host- server host name/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository namerepositoryPath- absolute folder or file path within repository. Folder paths should end with a '/' character.- Returns:
- Ghidra Server repository content URL
-
makeURL
public static URL makeURL(String host, int port, String repositoryName, String repositoryPath, String ref) Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.- Parameters:
host- server host name/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository namerepositoryPath- absolute folder or file path within repository.ref- ref or null Folder paths should end with a '/' character.- Returns:
- Ghidra Server repository content URL
-
makeURL
public static URL makeURL(String host, int port, String repositoryName, String repositoryFolderPath, String fileName, String ref) Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.- Parameters:
host- server host name/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository namerepositoryFolderPath- absolute folder path within repository.fileName- name of a file or folder contained within the specifiedrepositoryFolderPathref- optional URL ref or null Folder paths should end with a '/' character.- Returns:
- Ghidra Server repository content URL
- Throws:
IllegalArgumentException- if invalid arguments are specified
-
makeURL
Create a URL which refers to Ghidra Server repository and its root folder- Parameters:
host- server host name/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository name- Returns:
- Ghidra Server repository URL
-