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
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getDisplayString
(URL url) Generate preferred display string for Ghidra URLs.static URL
getFolderURL
(URL ghidraUrl) Force the specified URL to specify a folder.static URL
getNormalizedURL
(URL url) Get a normalized URL which eliminates use of host names and optional URL ref which may prevent direct comparison.static String
getProjectPathname
(URL ghidraUrl) Get the project pathname referenced by the specified Ghidra file/folder URL.static ProjectLocator
getProjectStorageLocator
(URL localProjectURL) Get the project locator which corresponds to the specified local project URL.static URL
getProjectURL
(URL ghidraUrl) Get Ghidra URL which corresponds to the local-project or repository with any file path or query details removed.static String
getRepositoryName
(URL url) Get the shared repository name associated with a repository URL or null if not applicable.static boolean
isGhidraURL
(String str) Determine if the specified string appears to be a possible ghidra URL (starts with "ghidra:/").static boolean
isGhidraURL
(URL url) Tests if the given url is using the Ghidra protocolstatic boolean
isLocalGhidraURL
(String str) Determine if URL string uses a local format (e.g.,ghidra:/path...
).static boolean
isLocalProjectURL
(URL url) Determine if the specified URL is a local project URL.static boolean
isServerRepositoryURL
(URL url) Determine if the specified URL is any type of server "repository" URL.static boolean
isServerURL
(String str) Determine if URL string uses a remote server format (e.g.,ghidra://host...
).static boolean
isServerURL
(URL url) Determine if the specified URL is any type of supported server Ghidra URL.static boolean
localProjectExists
(URL url) Determine if the specified URL refers to a local project and it exists.static URL
makeURL
(ProjectLocator projectLocator) Create a URL which refers to a local Ghidra projectstatic URL
makeURL
(ProjectLocator projectLocator, String projectFilePath, String ref) Create a URL which refers to a local Ghidra project with optional project file and refstatic URL
Create a URL which refers to Ghidra Server repository and its root folderstatic URL
Create a URL which refers to Ghidra Server repository content.static URL
Create a URL which refers to Ghidra Server repository content.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.static URL
Create a URL which refers to a local Ghidra projectstatic URL
Create a URL which refers to a local Ghidra project with optional project file and refstatic URL
Create 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 validlocal 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 Ghidra URL which corresponds to the local-project or repository with any file path or query details removed.- Parameters:
ghidraUrl
- ghidra file/folder URL (server-only URL not permitted)- Returns:
- local-project or repository URL
- Throws:
IllegalArgumentException
- if URL does not specify theghidra
protocol or does not properly identify a remote repository or local project.
-
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
-
getFolderURL
Force the specified URL to specify a folder. This may be neccessary when only folders are supported since Ghidra permits both a folder and file to have the same name within its parent folder. This method simply ensures that the URL path ends with a/
character if needed.- Parameters:
ghidraUrl
- ghidra URL- Returns:
- ghidra folder URL
- Throws:
IllegalArgumentException
- if specified URL is niether avalid remote server URL
orlocal project URL
.
-
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
- ifprojectLocator
does 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 invalidprojectFilePath
specified 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 specifiedrepositoryFolderPath
ref
- optional URL ref or null Folder paths should end with a '/' character.- Returns:
- Ghidra Server repository content URL
- Throws:
IllegalArgumentException
- if required arguments are blank or invalid
-
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
-