├── .github
└── workflows
│ ├── maven-develop-publish.yml
│ └── maven-release.yml
├── .gitignore
├── .idea
├── .gitignore
├── compiler.xml
├── encodings.xml
├── jarRepositories.xml
├── misc.xml
└── vcs.xml
├── LICENSE
├── README.md
├── assets
└── logo.jpeg
├── pom.xml
└── src
└── main
├── java
└── com
│ └── cosades
│ └── salsa
│ ├── Scanner.java
│ ├── cache
│ └── ObjectFieldCache.java
│ ├── client
│ ├── BaseClient.java
│ ├── HttpClient.java
│ └── SFClient.java
│ ├── configuration
│ ├── AuraConfiguration.java
│ └── SalesforceSObjectsConfiguration.java
│ ├── enumeration
│ └── SalesforceAuraHttpResponseBodyActionsStateEnum.java
│ ├── exception
│ ├── HttpClientBadUrlException.java
│ ├── SalesforceAuraAuthenticationException.java
│ ├── SalesforceAuraClientBadRequestException.java
│ ├── SalesforceAuraClientCSRFException.java
│ ├── SalesforceAuraClientNotSyncException.java
│ ├── SalesforceAuraInvalidParameters.java
│ ├── SalesforceAuraMissingRecordIdException.java
│ ├── SalesforceAuraUnauthenticatedException.java
│ ├── SalesforceInvalidIdException.java
│ └── SalesforceSOAPParsingException.java
│ ├── pojo
│ ├── HttpReponsePojo.java
│ ├── SOAPRequestBodyPojo.java
│ ├── SalesforceAuraCredentialsPojo.java
│ ├── SalesforceAuraHttpRequestBodyPojo.java
│ ├── SalesforceAuraHttpResponseBodyActionsPojo.java
│ ├── SalesforceAuraHttpResponseBodyContextGlobalValueProviderPojo.java
│ ├── SalesforceAuraHttpResponseBodyContextPojo.java
│ ├── SalesforceAuraHttpResponseBodyEventsAttributesDto.java
│ ├── SalesforceAuraHttpResponseBodyEventsPojo.java
│ ├── SalesforceAuraHttpResponseBodyPojo.java
│ ├── SalesforceAuraMessagePojo.java
│ ├── SalesforceItemKeyPojo.java
│ ├── SalesforceRESTSObjectsDescriptionHttpResponseBodyFieldsPojo.java
│ ├── SalesforceRESTSObjectsDescriptionHttpResponseBodyPojo.java
│ ├── SalesforceRESTSObjectsHttpResponseBodySobjectsItemPojo.java
│ ├── SalesforceRESTSObjectsListHttpResponseBodyPojo.java
│ ├── SalesforceRESTSObjectsRecentHttpResponseBodyPojo.java
│ ├── SalesforceSObjectFieldPojo.java
│ └── SalesforceSObjectPojo.java
│ └── utils
│ ├── ArgumentsParserUtils.java
│ ├── AuraHttpUtils.java
│ ├── DumpUtils.java
│ ├── HttpUtils.java
│ ├── RESTHTTPUtils.java
│ ├── SOAPRequestFactory.java
│ ├── SOAPUtils.java
│ ├── SObjectUtils.java
│ └── SalesforceIdGenerator.java
└── resources
├── logback.xml
├── salesforce-aura-actions-createrecord.json
├── salesforce-aura-actions-getrecord.json
├── salesforce-aura-actions-getrecordfields.json
├── salesforce-aura-actions-getrecordinfo.json
├── salesforce-aura-actions-getrecords.json
├── salesforce-aura-actions-getrecordtypes.json
├── salesforce-aura-actions-login.json
├── salesforce-aura-actions-writerecordfields.json
├── salesforce-aura-apps.txt
├── salesforce-aura-descriptors.txt
├── salesforce-aura-misc.properties
├── salesforce-aura-objects.txt
└── salesforce-aura-uris.txt
/.github/workflows/maven-develop-publish.yml:
--------------------------------------------------------------------------------
1 | name: Maven Package - Trigger
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | build:
8 |
9 | runs-on: ubuntu-latest
10 | permissions:
11 | contents: read
12 | packages: write
13 |
14 | steps:
15 | - uses: actions/checkout@v4
16 | with:
17 | ref: develop
18 | - name: Set up JDK 17
19 | uses: actions/setup-java@v3
20 | with:
21 | java-version: '17'
22 | distribution: 'temurin'
23 | server-id: github
24 | settings-path: ${{ github.workspace }}
25 |
26 | - name: Build with Maven
27 | run: mvn -B package --file pom.xml
28 |
29 | - name: Publish to GitHub Packages Apache Maven
30 | run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
31 | env:
32 | GITHUB_TOKEN: ${{ github.token }}
33 |
--------------------------------------------------------------------------------
/.github/workflows/maven-release.yml:
--------------------------------------------------------------------------------
1 | name: Maven Package and Release
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | build:
10 |
11 | runs-on: ubuntu-latest
12 | permissions:
13 | contents: write
14 | actions: write
15 | repository-projects: write
16 | packages: write
17 |
18 | steps:
19 | - uses: actions/checkout@v4
20 | with:
21 | ref: main
22 |
23 | - name: Release
24 | uses: qcastel/github-actions-maven-release@v1.12.41
25 | env:
26 | JAVA_HOME: /usr/lib/jvm/java-17-openjdk/
27 | with:
28 | maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Dmaven.deploy.skip=true"
29 | git-release-bot-name: "cosad3s (bot)"
30 | git-release-bot-email: "cosad3s@outlook.com"
31 | release-branch-name: main
32 | ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
33 |
34 | - name: Get the new tag
35 | id: get_tag
36 | run: echo "::set-output name=tag::$(git describe --tags $(git rev-list --tags --max-count=1))"
37 |
38 | - name: Create the release
39 | uses: softprops/action-gh-release@v2
40 | with:
41 | name: Release ${{ steps.get_tag.outputs.tag }}
42 | tag_name: ${{ steps.get_tag.outputs.tag }}
43 | files: |
44 | target/salsa-jar-with-dependencies.jar
45 | make_latest: true
46 | token: ${{ github.token }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/intellij,java,maven
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=intellij,java,maven
3 |
4 | ### Intellij ###
5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
6 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
7 |
8 | # User-specific stuff
9 | .idea/**/workspace.xml
10 | .idea/**/tasks.xml
11 | .idea/**/usage.statistics.xml
12 | .idea/**/dictionaries
13 | .idea/**/shelf
14 |
15 | # AWS User-specific
16 | .idea/**/aws.xml
17 |
18 | # Generated files
19 | .idea/**/contentModel.xml
20 |
21 | # Sensitive or high-churn files
22 | .idea/**/dataSources/
23 | .idea/**/dataSources.ids
24 | .idea/**/dataSources.local.xml
25 | .idea/**/sqlDataSources.xml
26 | .idea/**/dynamic.xml
27 | .idea/**/uiDesigner.xml
28 | .idea/**/dbnavigator.xml
29 |
30 | # Gradle
31 | .idea/**/gradle.xml
32 | .idea/**/libraries
33 |
34 | # Gradle and Maven with auto-import
35 | # When using Gradle or Maven with auto-import, you should exclude module files,
36 | # since they will be recreated, and may cause churn. Uncomment if using
37 | # auto-import.
38 | # .idea/artifacts
39 | # .idea/compiler.xml
40 | # .idea/jarRepositories.xml
41 | # .idea/modules.xml
42 | # .idea/*.iml
43 | # .idea/modules
44 | # *.iml
45 | # *.ipr
46 |
47 | # CMake
48 | cmake-build-*/
49 |
50 | # Mongo Explorer plugin
51 | .idea/**/mongoSettings.xml
52 |
53 | # File-based project format
54 | *.iws
55 |
56 | # IntelliJ
57 | out/
58 |
59 | # mpeltonen/sbt-idea plugin
60 | .idea_modules/
61 |
62 | # JIRA plugin
63 | atlassian-ide-plugin.xml
64 |
65 | # Cursive Clojure plugin
66 | .idea/replstate.xml
67 |
68 | # SonarLint plugin
69 | .idea/sonarlint/
70 |
71 | # Crashlytics plugin (for Android Studio and IntelliJ)
72 | com_crashlytics_export_strings.xml
73 | crashlytics.properties
74 | crashlytics-build.properties
75 | fabric.properties
76 |
77 | # Editor-based Rest Client
78 | .idea/httpRequests
79 |
80 | # Android studio 3.1+ serialized cache file
81 | .idea/caches/build_file_checksums.ser
82 |
83 | ### Intellij Patch ###
84 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
85 |
86 | # *.iml
87 | # modules.xml
88 | # .idea/misc.xml
89 | # *.ipr
90 |
91 | # Sonarlint plugin
92 | # https://plugins.jetbrains.com/plugin/7973-sonarlint
93 | .idea/**/sonarlint/
94 |
95 | # SonarQube Plugin
96 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
97 | .idea/**/sonarIssues.xml
98 |
99 | # Markdown Navigator plugin
100 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
101 | .idea/**/markdown-navigator.xml
102 | .idea/**/markdown-navigator-enh.xml
103 | .idea/**/markdown-navigator/
104 |
105 | # Cache file creation bug
106 | # See https://youtrack.jetbrains.com/issue/JBR-2257
107 | .idea/$CACHE_FILE$
108 |
109 | # CodeStream plugin
110 | # https://plugins.jetbrains.com/plugin/12206-codestream
111 | .idea/codestream.xml
112 |
113 | # Azure Toolkit for IntelliJ plugin
114 | # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
115 | .idea/**/azureSettings.xml
116 |
117 | ### Java ###
118 | # Compiled class file
119 | *.class
120 |
121 | # Log file
122 | *.log
123 |
124 | # BlueJ files
125 | *.ctxt
126 |
127 | # Mobile Tools for Java (J2ME)
128 | .mtj.tmp/
129 |
130 | # Package Files #
131 | *.jar
132 | *.war
133 | *.nar
134 | *.ear
135 | *.zip
136 | *.tar.gz
137 | *.rar
138 |
139 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
140 | hs_err_pid*
141 | replay_pid*
142 |
143 | ### Maven ###
144 | target/
145 | pom.xml.tag
146 | pom.xml.releaseBackup
147 | pom.xml.versionsBackup
148 | pom.xml.next
149 | release.properties
150 | dependency-reduced-pom.xml
151 | buildNumber.properties
152 | .mvn/timing.properties
153 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
154 | .mvn/wrapper/maven-wrapper.jar
155 |
156 | # Eclipse m2e generated files
157 | # Eclipse Core
158 | .project
159 | # JDT-specific (Eclipse Java Development Tools)
160 | .classpath
161 |
162 | # End of https://www.toptal.com/developers/gitignore/api/intellij,java,maven
163 |
164 | # Tool outputs
165 | output*
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SALSA - *SALesforce Scanner for Aura (and beyond)*
2 |
3 |
4 |
5 |
6 | **SALSA** has been developped on a lot of my personal free time, to help me on pentesting and bug hunting activites against Salesforce Lightning (Aura) and API assets. Please note it is fully experimental.
7 |
8 | I decided to share it for free, to help the community.
9 | *If you would ever like to buy me a coffee or a beer* 😇 :
10 |
11 | [](https://www.buymeacoffee.com/cosades)
12 |
13 |
14 |
15 | ## Features
16 |
17 | - Enumeration and/or dump data records (*and sub-records*) from:
18 | - Aura controllers
19 | - Services API (Direct sObjects `/services/data/v60.0/sobjects` or SOQL `/services/data/v60.0/query/`)
20 | - SOAP (`/services/Soap/c/`)
21 | - Works as unauthenticated or authenticated user (*username / password or `sid` or `aura.token`*).
22 | - Enumeration records entities types (with or without custom entities `*__c` filtering) from:
23 | - Target APIs harvesting
24 | - And/or Salesforce packages reflections
25 | - And/or encountered entities in the wild
26 | - Test for targetted record identifier.
27 | - Bruteforcing record identifiers.
28 | - ⚠️ Automatized test for arbitrary records creation.
29 | - ⚠️ Automatized test for arbitrary records fields edition.
30 | - *And more: routing to HTTP proxy for investigation, custom User-Agent, automatized finding of entities fields, auto-detect FWUID, etc.*
31 |
32 | ⚠️: *dangerous & experimental*
33 |
34 | ## Usage
35 |
36 | ### Help
37 |
38 | ```bash
39 | usage: SALSA 💃⚡ - SALesforce Scanner for Aura (and beyond)
40 | [-h] -t TARGET [-u USERNAME] [-p PASSWORD] [--sid SID] [--token TOKEN] [--path PATH] [--id ID] [--bruteforce] [--types TYPES] [--update] [--create] [--ua UA] [--proxy PROXY] [--dump]
41 | [--output OUTPUT] [--typesintrospection] [--typeswordlist] [--typesapi] [--custom] [--app APP] [--force] [--debug] [--trace]
42 |
43 | Enumeration of vulnerabilities and misconfiguration against Salesforce endpoint.
44 |
45 | named arguments:
46 | -h, --help show this help message and exit
47 | -t TARGET, --target TARGET
48 | Target URL
49 | -u USERNAME, --username USERNAME
50 | Username (for authenticated mode)
51 | -p PASSWORD, --password PASSWORD
52 | Password (for authenticated mode)
53 | --sid SID The SID cookie value (for authenticated mode - instead of username/password)
54 | --token TOKEN The aura token (for authenticated mode - instead of username/password)
55 | --path PATH Set specific base path.
56 | --id ID Find a specific record from its id.
57 | --bruteforce Enable bruteforce of Salesforce identifiers from a specific record id (from --recordid). (default: false)
58 | --types TYPES Target record(s) only from following type(s) (should be comma-separated).
59 | --update Test for record fields update permissions (WARNING: will inject data in the app!). (default: false)
60 | --create Test for record creation permissions (WARNING: will inject data in the app!). (default: false)
61 | --ua UA Set specific User-Agent.
62 | --proxy PROXY Use following HTTP proxy (ex: 127.0.0.1:8080).
63 | --dump Dump records as Json files. (default: false)
64 | --output OUTPUT Output folder for dumping records as Json files.
65 | --typesintrospection Use record types from Salesforce package introspection. (default: false)
66 | --typeswordlist Use record types from internal wordlist. (default: false)
67 | --typesapi Use record types from APIs on the target. (default: false)
68 | --custom Only target custom record types (*__c). (default: false)
69 | --app APP Custom AURA App Name.
70 | --force Continue the scanning actions even if in case of incoherent or incorrect results. (default: false)
71 | --debug Increase the log level to DEBUG mode. (default: false)
72 | --trace Increase the log level to TRACE mode. (default: false)
73 | ```
74 |
75 | ### Examples
76 |
77 |
78 | Simple scan - Unauthenticated
79 |
80 | ```bash
81 | java -jar target/salsa-jar-with-dependencies.jar -t https://www.target.com --typesapi
82 |
83 | [*] Searching for Salesforce Aura instance on https://www.target.com ...
84 | [!] Found Salesforce Aura instance on path: /aura
85 | [!] Scan will continue as unauthenticated (guest) user ...
86 | [*] Looking for all objects with standard or custom types.
87 | [*] Will retrieve all sObjects types known by the target from Aura service.
88 | [*] Found 2111 object types from Salesforce Aura service!
89 | [*] Will retrieve all sObjects types known by the target from REST sObject API.
90 | [*] Aura: looking for records for type AINaturalLangProcessRslt
91 | [*] Aura: looking for records for type AINtrlLangProcChunkRslt
92 | [*] Aura: looking for records for type AIPredictionScore
93 | (...)
94 | ```
95 |
96 |
97 |
98 |
99 | Simple scan - Unauthenticated - Custom types only
100 |
101 | ```bash
102 | ❯ java -jar target/salsa-jar-with-dependencies.jar -t https://www.target.com --typesapi --custom
103 |
104 | [*] Searching for Salesforce Aura instance on https://www.target.com ...
105 | [!] Found Salesforce Aura instance on path: /aura
106 | [!] Scan will continue as unauthenticated (guest) user ...
107 | [*] Looking for all objects with standard or custom types.
108 | [*] Will retrieve all sObjects types known by the target from Aura service.
109 | [*] Found 2111 object types from Salesforce Aura service!
110 | [*] Will retrieve all sObjects types known by the target from REST sObject API.
111 | [*] Reducing to 4 custom object types.
112 | [*] Aura: looking for records for type CountryLanguage__c
113 | [*] Looking for sObject with recordId 00B0H000007t1qlUAA and type(s) [ListView].
114 | [!] The recordId 00B0H000007t1qlUAA cannot be found through descriptor serviceComponent://ui.force.components.controllers.detail.DetailController/ACTION$getRecord (error: We couldn't find the record you're trying to access. It may have been deleted by another user, or there may have been a system error. Ask your administrator for help.).
115 | [!] No records found from recordId 00B0H000007t1qlUAA and descriptor serviceComponent://ui.force.components.controllers.recordGlobalValueProvider.RecordGvpController/ACTION$getRecord: {objectMetadata={ListView={_nameField=Name, _entityLabel=List View, _keyPrefix=00B}}, quickActionRecordTemplates={}, recordErrors={00B0H000007t1qlUAA={message=We couldn't find the record you're trying to access. It may have been deleted by another user, or there may have been a system error. Ask your administrator for help.}}, records={}, recordTemplates={}, resolvedDraftIds=[], quickActionMetadata={}, refreshErrors=[], requestIds={00B0H000007t1qlUAA=[00B0H000007t1qlUAA.null.null.null.Id.VIEW]}, purgedRecordIds=[], layouts={}}
116 | [*] Aura: looking for records for type Country__c
117 | [*] Looking for sObject with recordId 00B0H000007t1qgUAA and type(s) [ListView].
118 | (...)
119 | ```
120 |
121 |
122 |
123 |
124 | Simple scan - Unauthenticated - Targetted record type and bruteforce
125 |
126 | ```bash
127 | ❯ java -jar target/salsa-jar-with-dependencies.jar -t https://www.target.com --types Store__History --id 0176S0001GvGwvEQQS --bruteforce
128 | Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
129 | [*] Searching for Salesforce Aura instance on https://www.target.com ...
130 | [!] Found Salesforce Aura instance on path: /aura
131 | [!] Scan will continue as unauthenticated (guest) user ...
132 | [*] Looking for sObject with recordId 0176S0001GvGwvMQQS and type(s) [Store__History].
133 | [!] Cannot find fields for object type Store__History through descriptor aura://RecordUiController/ACTION$getObjectInfo.
134 | [!] Cannot find record with fields for ID 0176S0001GvGwvMQQS and type Store__History.
135 | [!] The recordId 0176S0001GvGwvMQQS cannot be found through descriptor serviceComponent://ui.force.components.controllers.detail.DetailController/ACTION$getRecord (error: You don't have access to this record. Ask your administrator for help or to request access.).
136 | [!] No records found from recordId 0176S0001GvGwvMQQS and descriptor serviceComponent://ui.force.components.controllers.recordGlobalValueProvider.RecordGvpController/ACTION$getRecord: {objectMetadata={}, quickActionRecordTemplates={}, recordErrors={0176S0001GvGwvMQQS={message=You don't have access to this record. Ask your administrator for help or to request access., inaccessible=true}}, records={}, recordTemplates={}, resolvedDraftIds=[], quickActionMetadata={}, refreshErrors=[], requestIds={0176S0001GvGwvMQQS=[0176S0001GvGwvMQQS.null.null.null.Id.VIEW]}, purgedRecordIds=[], layouts={}}
137 | [*] Looking for sObject with recordId 0176S0001GvGwvNQQS and type(s) [Store__History].
138 | [!] Cannot find record with fields for ID 0176S0001GvGwvNQQS and type Store__History.
139 | [!] The recordId 0176S0001GvGwvNQQS cannot be found through descriptor serviceComponent://ui.force.components.controllers.detail.DetailController/ACTION$getRecord (error: You don't have access to this record. Ask your administrator for help or to request access.).
140 | [!] No records found from recordId 0176S0001GvGwvNQQS and descriptor serviceComponent://ui.force.components.controllers.recordGlobalValueProvider.RecordGvpController/ACTION$getRecord: {objectMetadata={}, quickActionRecordTemplates={}, recordErrors={0176S0001GvGwvNQQS={message=You don't have access to this record. Ask your administrator for help or to request access., inaccessible=true}}, records={}, recordTemplates={}, resolvedDraftIds=[], quickActionMetadata={}, refreshErrors=[], requestIds={0176S0001GvGwvNQQS=[0176S0001GvGwvNQQS.null.null.null.Id.VIEW]}, purgedRecordIds=[], layouts={}}
141 | [*] Looking for sObject with recordId 0176S0001GvGwvLQQS and type(s) [Store__History].
142 | [!] Cannot find record with fields for ID 0176S0001GvGwvLQQS and type Store__History.
143 | [!] The recordId 0176S0001GvGwvLQQS cannot be found through descriptor serviceComponent://ui.force.components.controllers.detail.DetailController/ACTION$getRecord (error: You don't have access to this record. Ask your administrator for help or to request access.).
144 | [!] No records found from recordId 0176S0001GvGwvLQQS and descriptor serviceComponent://ui.force.components.controllers.recordGlobalValueProvider.RecordGvpController/ACTION$getRecord: {objectMetadata={}, quickActionRecordTemplates={}, recordErrors={0176S0001GvGwvLQQS={message=You don't have access to this record. Ask your administrator for help or to request access., inaccessible=true}}, records={}, recordTemplates={}, resolvedDraftIds=[], quickActionMetadata={}, refreshErrors=[], requestIds={0176S0001GvGwvLQQS=[0176S0001GvGwvLQQS.null.null.null.Id.VIEW]}, purgedRecordIds=[], layouts={}}
145 | [*] Looking for sObject with recordId 0176S0001GvGwvKQQS and type(s) [Store__History].
146 | (...)
147 | ```
148 |
149 |
150 |
151 |
152 | Simple scan - Authenticated - Targetted record type
153 |
154 | ```bash
155 | ❯ java -jar target/salsa-jar-with-dependencies.jar -t https://www.target.com --types User --sid '00Di000.REDACTED' --token "eyJ2ZXIiOi.REDACTED"
156 | Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
157 | [*] Searching for Salesforce Aura instance on https://www.target.com ...
158 | [!] Found Salesforce Aura instance on path: /aura
159 | [!] Will try with explicitly provided credentials {username=''}
160 | [*] Looking for all objects with type(s) [User].
161 | [*] Aura: looking for records for type User
162 | [!] Client is out-of-sync. Will retry with new FWUID: WFIwUmVJdm.REDACTED
163 | [*] Looking for sObject with recordId 005ixxxxx and type(s) [User].
164 | [*] Found 190 fields for sObject type User from Aura service.
165 | [*] Found record 005ixxxxxx with descriptor serviceComponent://ui.force.components.controllers.detail.DetailController/ACTION$getRecord!
166 | [*] 1 object(s) retrieved with descriptor serviceComponent://ui.force.components.controllers.lists.selectableListDataProvider.SelectableListDataProviderController/ACTION$getItems from object type User!
167 | [*] End of scanning of https://www.target.com
168 | ```
169 |
170 |
171 |
172 |
173 | Simple scan - Authenticated - Custom record types dump
174 |
175 | ```bash
176 | ❯ java -jar target/salsa-jar-with-dependencies.jar -t https://www.target.com --typesapi --custom --sid '00Di000.REDACTED' --token "eyJ2ZXIiOi.REDACTED" --dump --proxy 127.0.0.1:8080
177 | Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
178 | [*] Searching for Salesforce Aura instance on https://www.target.com ...
179 | [!] Found Salesforce Aura instance on path: /aura
180 | [!] Will try with explicitly provided credentials {username=''}
181 | [*] Looking for all objects with standard or custom types.
182 | [*] Will retrieve all sObjects types known by the target from Aura service.
183 | [!] Client is out-of-sync. Will retry with new FWUID: WFIwUmVJ...REDACTED
184 | [*] Found 2111 object types from Salesforce Aura service!
185 | [*] Will retrieve all sObjects types known by the target from REST sObject API.
186 | [*] Found 279 object types from Salesforce REST sObject API!
187 | [*] Reducing to 24 custom object types.
188 | [*] Aura: looking for records for type MyOtherType__c
189 | [*] SOAP: looking for records for type MyOtherType__c
190 | [*] Found 0 entities of types MyOtherType__c through SOAP API!
191 | [*] Query Data API: looking for records for type MyOtherType__c
192 | [*] SObject Data API: looking for records for type MyOtherType__c
193 | [*] Aura: looking for records for type Wonderful__c
194 | [*] SOAP: looking for records for type Wonderful__c
195 | [*] Found 0 entities of types Wonderful__c through SOAP API!
196 | [*] Query Data API: looking for records for type Wonderful__c
197 | [*] SObject Data API: looking for records for type Wonderful__c
198 | [*] Aura: looking for records for type MyOtherTypeAgain__c
199 | [*] SOAP: looking for records for type MyOtherTypeAgain__c
200 | [*] Found 0 entities of types MyOtherTypeAgain__c through SOAP API!
201 | [*] Query Data API: looking for records for type MyOtherTypeAgain__c
202 | [*] SObject Data API: looking for records for type MyOtherTypeAgain__c
203 | [*] Aura: looking for records for type MyType__c
204 | [*] SOAP: looking for records for type MyType__c
205 | [*] Found 10 entities of types MyType__c through SOAP API!
206 | [*] Looking for sObject with recordId a4AREDACTED and type(s) [MyType__c].
207 | [!] Cannot find fields for object type MyType__c through descriptor aura://RecordUiController/ACTION$getObjectInfo.
208 | [*] Found 29 fields for sObject type MyType__c from REST sObject API.
209 | [!] Cannot find record with fields for ID a4AREDACTED and type MyType__c.
210 | [!] The recordId a4AREDACTED cannot be found through descriptor serviceComponent://ui.force.components.controllers.detail.DetailController/ACTION$getRecord (error: You don't have access to this record. Ask your administrator for help or to request access.).
211 | [!] No records found from recordId a4AREDACTED and descriptor serviceComponent://ui.force.components.controllers.recordGlobalValueProvider.RecordGvpController/ACTION$getRecord: {objectMetadata={}, quickActionRecordTemplates={}, recordErrors={a4AREDACTED={message=You don't have access to this record. Ask your administrator for help or to request access., inaccessible=true}}, records={}, recordTemplates={}, resolvedDraftIds=[], quickActionMetadata={}, refreshErrors=[], requestIds={a4AREDACTED=[a4AREDACTED.null.null.null.Id.VIEW]}, purgedRecordIds=[], layouts={}}
212 | [*] Found sObject a4AREDACTED of type MyType__c from REST sObject API: [MyType__c]{[[StartDateTime__c=2023-12-05T18:00:00.000+0000], [CreatedDate=2023-11-28T14:07:00.000+0000],....]}
213 | [*] Looking for sObject with recordId a4A6REDACTED and type(s) [MyType__c].
214 | [!] Cannot find record with fields for ID a4A6REDACTED and type MyType__c.
215 | (...)
216 | [*] Query Data API: looking for records for type TR_MyLV_Diamond__c
217 | [*] SObject Data API: looking for records for type TR_MyLV_Diamond__c
218 | [*] Will dump merged object a4AREDACTED to ./output2024.07.22.21.57.00/MyType__c/a4AREDACTED.json
219 | [*] Will dump merged object a2RREDACTED to ./output2024.07.22.21.57.00/MyOtherType__c/a2RREDACTED.json
220 | [*] Will dump merged object a0NREDACTED to ./output2024.07.22.21.57.00/MyOtherTypeAgain__c/a0NREDACTED.json
221 | (...)
222 | ```
223 |
224 | **Dumped records will be stored into a timestamped output folder**
225 |
226 |
227 |
228 | ## Current limitations
229 |
230 | - SOAP `query` requests are limited to 10 items.
231 | - Bruteforcing IDs is limited to 10 items.
232 |
233 | ## TODO
234 |
235 | *Release date: maybe one day*
236 |
237 | - [ ] Find & add alternatives authentications.
238 | - [ ] Detect `debug` mode arbitrary activation ([https://www.cosades.com/posts/sf_debug_mode](https://www.cosades.com/posts/sf_debug_mode)).
239 | - [ ] Download item for *Document* type identifier (hit `https://ATTACHMENTS_DOMAIN/sfc/servlet.shepherd/version/download/` - *URL can also be found in `Generic_DocumentDownloadPathUrl` attribute from descriptor `serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent`*)
240 | - [ ] Data API - Composite: `/services/data/vXX.0/composite/batch` (POST, with examples parameters: `{"batchRequests": [{"method": "PATCH", "url": "v38.0/sobjects/OpportunityLineItem/", "richInput": {"End_Date__c": "2017-01-19"}]}}`)
241 | - [ ] Data API - Anonymous APEX execution: `/services/data/vXX.0/tooling/executeAnonymous/?anonymousBody=`
242 | - [ ] Async API - Job: `/services/async/xx.0/job` (POST and `updateCSV` or `Closed`). Other related endpoints: `/services/data/v60.0/jobs/query`, `/services/async/xx.0/job/JOBID`, `/services/async/xx.0/job/JOBID/batch`, `/services/async/xx.0/job/JOBID/batch/BATCHID/result`
243 | - [ ] Apex REST API: `/services/apexrest/SoapMessage`, `/services/apexrest/Cases`
244 | - [ ] Find the parameters for other classic Aura controllers 🥹
245 |
246 | ## Troubleshooting
247 |
248 | > **Disclaimer: "spaghetti code" here, due to Salesforce technical contexts discoveries, mixed between official documentations, write-ups, reverse engineering, empirical tests. Hence I could study for small new features proposals or major bug fixes, this tool is now hard to maintain.**
249 |
250 | ***Then, before opening an issue, please consider the following points:***
251 |
252 | 1. I strongly encourage you to **switch the logging level** to `DEBUG` or `TRACE` level (`--debug` / `--trace`).
253 | 2. The tool can send **thousand of requests** and **works for hours**. Two possible consequences:
254 |
255 | - **You can be banned** by the target.
256 | - **The authentication could have a short expiration time on your target**. *I do not know how to detect & manage that part, there is no real homogeneous behaviour for this.* I could only suggest you to reduce the record types to test.
257 |
258 | 3. I think the tool is adapted to most of Salesforce contexts, **but not all of them**.
259 | 4. Route the tool **an HTTP proxy** for further investigation (`--proxy 127.0.0.1:8080` for instance)
260 |
261 | ## Q/A
262 |
263 | *Why is the authentication username/password does not work ?*
264 |
265 | > Because the target is maybe not using the Aura Controller `apex://LightningLoginFormController/ACTION$login`: prefer using the `sid` (session id) or `token` (Aura token) after a manual authentication.
266 |
267 | *What's is the difference between `sid` and `token` ?*
268 |
269 | > The `token` is used for authenticated Aura controller interactions. The `sid` is used to interact with other APIs (and sometimes Aura controllers). The format are not the same though: for the `token` it is more like a JWT, for the `sid` it is prefixed by the organization identifier.
270 |
271 | *Why there are limitations regarding the amount of data dump in queries for example ?*
272 |
273 | > Yes, it could be improved with new arguments. The initial reason was that the tool can launch thousand of requests and could last for hours (Entities count / fields cound / controllers count / services count / etc.). The limitations are present to reduce the duration. Feel free to change that.
274 |
275 | *How do I find targets ?*
276 |
277 | > It is up to you, but it can be done with nuclei: `nuclei -rl 10 -t "http/misconfiguration/salesforce-aura.yaml" -l subdomains.txt`
278 |
279 | *Why the source code is so complex ? Why Java ?*
280 |
281 | > In the beginning it was a clean set of small scripts. Discoveries after discoveries, I have added, modified, removed some parts. Without unit tests. And Salesforce contexts are very complex / customisable, targets behaviors can differ and code is adapted with some unelegant if/then/else. The last reason is that I wanted to have the most adaptable and automatized tool for this kind of assessment. I dig into complex workflows, but abandonned some steps. Why Java ? Because Salesforce APEX is very close to Java, and Salesforce have some libraries in Java which could be decompiled to be dynamically integrated into the tool. And I like Java (nobody is perfect).
282 |
283 | ## Credits and ressources
284 |
285 | Thanks for all these ressources (tools, write-ups, docs, ...), which help me a lot:
286 |
287 | - https://www.fishofprey.com/
288 | - https://developer.salesforce.com/
289 | - https://developer.salesforce.com/blogs/tech-pubs/2017/01/simplify-your-api-code-with-new-composite-resources
290 | - https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources.htm
291 | - https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_traceflag.htm
292 | - https://www.varonis.com/blog/abusing-salesforce-communities
293 | - https://github.com/tedconn/lwr-mobify
294 | - https://github.com/Ophion-Security/sret
295 | - https://github.com/forcedotcom/aura
296 | - https://github.com/jeffzmartin/SalesforceSQLSchemaGenerator
297 | - https://github.com/LTiDi2000/SFMisCheck/blob/main/sf.py
298 | - https://github.com/pingidentity/AuraIntruder/
299 | - https://www.youtube.com/watch?v=wHqp6laTnio
300 | - https://web.archive.org/web/20201031233746/https://www.enumerated.de/index/salesforce
301 | - https://codefriar.wordpress.com/2014/10/30/eval-in-apex-secure-dynamic-code-evaluation-on-the-salesforce1-platform/
302 | - https://blog.intigriti.com/hacking-tools/hacking-salesforce-lightning-guide-for-bug-hunters
303 |
304 | ## Licence
305 |
306 | Released under [GPL-3.0 license](/LICENSE).
307 |
--------------------------------------------------------------------------------
/assets/logo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cosad3s/salsa/9209f2101873f69c64cb23c96b78807c4b307d66/assets/logo.jpeg
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.cosades
6 | salsa
7 | 1.0.2-SNAPSHOT
8 |
9 |
10 | 17
11 | 17
12 | UTF-8
13 | 1.18.28
14 | 1.5.5.Final
15 | 0.9.0
16 | 2.14.2
17 | 5.2.3
18 | 3.14.0
19 | 1.10.0
20 | 1.4.14
21 | 2.0.9
22 | 59.0.0
23 | 57.0.3
24 | 0.10.2
25 | 3.3
26 |
27 |
28 |
29 |
30 | net.sourceforge.argparse4j
31 | argparse4j
32 | ${argparse4j.version}
33 |
34 |
35 | org.projectlombok
36 | lombok
37 | ${lombok.version}
38 | provided
39 |
40 |
41 | org.mapstruct
42 | mapstruct
43 | ${org.mapstruct.version}
44 |
45 |
46 | com.fasterxml.jackson.core
47 | jackson-core
48 | ${jackson.version}
49 |
50 |
51 | com.fasterxml.jackson.core
52 | jackson-databind
53 | ${jackson.version}
54 |
55 |
56 | org.apache.httpcomponents.client5
57 | httpclient5
58 | ${httpclient.version}
59 |
60 |
61 | org.apache.commons
62 | commons-lang3
63 | ${commons-lang.version}
64 |
65 |
66 | org.apache.commons
67 | commons-text
68 | ${common-text.version}
69 |
70 |
71 | org.slf4j
72 | slf4j-api
73 | ${slf4j.version}
74 |
75 |
76 | ch.qos.logback
77 | logback-classic
78 | ${logback.version}
79 |
80 |
81 | ch.qos.logback
82 | logback-core
83 | ${logback.version}
84 |
85 |
86 | io.github.apex-dev-tools
87 | sobject-types
88 | ${salesforce.dev.version}
89 |
90 |
91 | org.reflections
92 | reflections
93 | ${reflections.version}
94 |
95 |
96 | com.force.api
97 | force-wsc
98 | ${salesforce.version}
99 |
100 |
101 | *
102 | *
103 |
104 |
105 |
106 |
107 | com.force.api
108 | force-partner-api
109 | ${salesforce.version}
110 |
111 |
112 | *
113 | *
114 |
115 |
116 |
117 |
118 | org.objenesis
119 | objenesis
120 | ${objenesis.version}
121 |
122 |
123 |
124 |
125 |
126 |
127 | org.apache.maven.plugins
128 | maven-compiler-plugin
129 |
130 |
131 |
132 | org.projectlombok
133 | lombok
134 | ${lombok.version}
135 |
136 |
137 | org.mapstruct
138 | mapstruct-processor
139 | ${org.mapstruct.version}
140 |
141 |
142 |
143 |
144 |
145 | maven-assembly-plugin
146 |
147 | salsa
148 |
149 | jar-with-dependencies
150 |
151 |
152 |
153 | com.cosades.salsa.Scanner
154 |
155 |
156 |
157 |
158 |
159 |
160 | single
161 |
162 | package
163 |
164 |
165 |
166 |
167 |
168 | maven-release-plugin
169 |
170 | [ci skip]
171 |
172 |
173 |
174 |
175 |
176 |
177 | scm:git:${project.scm.url}
178 | scm:git:${project.scm.url}
179 | git@github.com:cosad3s/salsa.git
180 | HEAD
181 |
182 |
183 |
--------------------------------------------------------------------------------
/src/main/java/com/cosades/salsa/Scanner.java:
--------------------------------------------------------------------------------
1 | package com.cosades.salsa;
2 |
3 | import ch.qos.logback.classic.Level;
4 | import com.cosades.salsa.client.SFClient;
5 | import com.cosades.salsa.configuration.SalesforceSObjectsConfiguration;
6 | import com.cosades.salsa.exception.*;
7 | import com.cosades.salsa.pojo.SalesforceAuraCredentialsPojo;
8 | import com.cosades.salsa.pojo.SalesforceSObjectPojo;
9 | import com.cosades.salsa.utils.ArgumentsParserUtils;
10 | import com.cosades.salsa.utils.DumpUtils;
11 | import com.cosades.salsa.utils.SalesforceIdGenerator;
12 | import org.apache.commons.lang3.StringUtils;
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 |
16 | import java.io.IOException;
17 | import java.text.SimpleDateFormat;
18 | import java.util.*;
19 |
20 | public class Scanner {
21 |
22 | private static final Logger logger = LoggerFactory.getLogger(Scanner.class);
23 |
24 | public static void main(String[] args) throws IOException {
25 | String target = ArgumentsParserUtils.getArgument(args, "target");
26 | String username = ArgumentsParserUtils.getArgument(args, "username");
27 | String password = ArgumentsParserUtils.getArgument(args, "password");
28 | String sid = ArgumentsParserUtils.getArgument(args, "sid");
29 | String token = ArgumentsParserUtils.getArgument(args, "token");
30 | String proxy = ArgumentsParserUtils.getArgument(args, "proxy");
31 | String userAgent = ArgumentsParserUtils.getArgument(args, "ua");
32 | String forcedPath = ArgumentsParserUtils.getArgument(args, "path");
33 | String recordId = ArgumentsParserUtils.getArgument(args, "id");
34 | String bruteforce = ArgumentsParserUtils.getArgument(args, "bruteforce");
35 | String initialRecordTypes = ArgumentsParserUtils.getArgument(args, "types");
36 | String doTestUpdate = ArgumentsParserUtils.getArgument(args, "update");
37 | String doTestCreate = ArgumentsParserUtils.getArgument(args, "create");
38 | String doDump = ArgumentsParserUtils.getArgument(args, "dump");
39 | String output = ArgumentsParserUtils.getArgument(args, "output");
40 | String recordtypesfromintrospection = ArgumentsParserUtils.getArgument(args, "typesintrospection");
41 | String recordtypesfromapi = ArgumentsParserUtils.getArgument(args, "typesapi");
42 | String recordtypesfromwordlist = ArgumentsParserUtils.getArgument(args, "typeswordlist");
43 | String appName = ArgumentsParserUtils.getArgument(args, "app");
44 | String force = ArgumentsParserUtils.getArgument(args, "force");
45 | String onlyCustomTypes = ArgumentsParserUtils.getArgument(args, "custom");
46 | String debug = ArgumentsParserUtils.getArgument(args, "debug");
47 | String trace = ArgumentsParserUtils.getArgument(args, "trace");
48 |
49 | if (Boolean.parseBoolean(debug)) {
50 | ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger("com.cosades");
51 | root.setLevel(Level.DEBUG);
52 | }
53 | if (Boolean.parseBoolean(trace)) {
54 | ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger("com.cosades");
55 | root.setLevel(Level.TRACE);
56 | }
57 |
58 | if (StringUtils.isBlank(output)) {
59 | output = "./output" + new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss", Locale.US).format(new Date());
60 | }
61 |
62 | if (Boolean.parseBoolean(recordtypesfromintrospection)) {
63 | logger.info("[*] Launching Salesforce scanner... (warming up, please wait)");
64 | SalesforceSObjectsConfiguration.init();
65 | }
66 |
67 | SFClient client = null;
68 | try {
69 | client = new SFClient(
70 | target,
71 | proxy,
72 | userAgent,
73 | Boolean.parseBoolean(recordtypesfromintrospection),
74 | Boolean.parseBoolean(recordtypesfromwordlist),
75 | Boolean.parseBoolean(recordtypesfromapi),
76 | Boolean.parseBoolean(onlyCustomTypes),
77 | appName);
78 | } catch (HttpClientBadUrlException e) {
79 | logger.error("[!] Invalid parameters.", e);
80 | System.exit(-1);
81 | }
82 |
83 | logger.info("[*] Searching for Salesforce Aura instance on {} ...", target);
84 | String foundPath = "";
85 | if (StringUtils.isNotBlank(forcedPath)) {
86 | foundPath = client.detectAura(forcedPath);
87 | } else {
88 | foundPath = client.detectAura();
89 | }
90 | if (StringUtils.isNotBlank(foundPath)) {
91 | logger.warn("[!] Found Salesforce Aura instance on path: {}", foundPath);
92 | } else {
93 | logger.error("[!] Warning: Salesforce Aura endpoint not found!");
94 | if (!Boolean.parseBoolean(force)) {
95 | System.exit(-1);
96 | } else {
97 | logger.warn("[!] Will continue anyway (usage of --force detected).");
98 | }
99 | }
100 |
101 | // Authentification
102 | if (StringUtils.isNotBlank(username)) {
103 | logger.info("[*] Login for Salesforce Aura instance...");
104 |
105 | if (password == null) {
106 | password = "";
107 | }
108 |
109 | SalesforceAuraCredentialsPojo credentials = new SalesforceAuraCredentialsPojo(username, password);
110 | try {
111 | client.login(credentials);
112 | } catch (SalesforceAuraAuthenticationException e) {
113 | logger.error("[!] Unable to authenticate with provided credentials.");
114 | }
115 | } else {
116 | if (StringUtils.isNotBlank(sid) || StringUtils.isNotBlank(token)) {
117 | SalesforceAuraCredentialsPojo credentials = new SalesforceAuraCredentialsPojo();
118 | credentials.setSid(sid);
119 | credentials.setToken(token);
120 | logger.warn("[!] Will try with explicitly provided credentials {}", credentials);
121 | client.updateCredentials(credentials);
122 | } else {
123 | logger.warn("[!] Scan will continue as unauthenticated (guest) user ...");
124 | }
125 | }
126 |
127 | String[] recordTypesList = null;
128 | if (StringUtils.isNotBlank(initialRecordTypes)) {
129 | recordTypesList = initialRecordTypes.split(",");
130 | }
131 |
132 | List objects = new ArrayList<>();
133 |
134 | // Read objects
135 | if (!Boolean.parseBoolean(doTestCreate)) {
136 |
137 | // Get specific object(s)
138 | if (StringUtils.isNotBlank(recordId)) {
139 |
140 | Set ids = new HashSet<>();
141 | ids.add(recordId);
142 |
143 | if (Boolean.parseBoolean(bruteforce)) {
144 | try {
145 | ids.addAll(SalesforceIdGenerator.generateIds(recordId, 10));
146 | } catch (SalesforceInvalidIdException e) {
147 | logger.error("[!] Invalid Salesforce record id for bruteforce operation.");
148 | System.exit(-1);
149 | }
150 | }
151 |
152 | for (String id : ids) {
153 | logger.debug("[x] Try to get {} records for identifiers {}", recordTypesList, ids);
154 | try {
155 | SalesforceSObjectPojo o = client.getObject(id, recordTypesList);
156 | if (o != null) {
157 | objects.add(o);
158 | }
159 |
160 | } catch (SalesforceAuraMissingRecordIdException e) {
161 | logger.error("[!] Cannot continue: missing recordId");
162 | System.exit(-1);
163 | } catch (SalesforceAuraInvalidParameters e) {
164 | logger.error("[!] Parameters are invalid.");
165 | System.exit(-1);
166 | } catch (SalesforceAuraClientBadRequestException e) {
167 | logger.error("[!] Error during API requests.");
168 | System.exit(-1);
169 | } catch (SalesforceAuraUnauthenticatedException e) {
170 | logger.error("[!] Cannot continue: authentication is mandatory.");
171 | System.exit(-1);
172 | }
173 | }
174 |
175 | // Get multiple objects without identifier
176 | } else {
177 | try {
178 | objects = client.getObjects(recordTypesList);
179 |
180 | } catch (SalesforceAuraClientBadRequestException e) {
181 | logger.error("[!] Error during API requests.");
182 | System.exit(-1);
183 | } catch (SalesforceAuraUnauthenticatedException e) {
184 | logger.error("[!] Cannot continue: authentication is mandatory.");
185 | System.exit(-1);
186 | }
187 | }
188 |
189 | if (Boolean.parseBoolean(doDump)) {
190 | DumpUtils.dump(objects, output);
191 | }
192 |
193 | // Test fields on read objects (from type(s) or id)
194 | if (Boolean.parseBoolean(doTestUpdate)) {
195 | if (objects.isEmpty()) {
196 | if (StringUtils.isNotBlank(recordId) && recordTypesList != null) {
197 | logger.warn("[!] Will test fields on arbitrary object {} of type {}", recordId, recordTypesList);
198 | try {
199 | client.writeToObjectFields(recordId, recordTypesList);
200 | } catch (SalesforceAuraClientBadRequestException e) {
201 | logger.error("[!] Error during API requests.");
202 | System.exit(-1);
203 | } catch (SalesforceAuraMissingRecordIdException e) {
204 | logger.error("[!] Missing recordId for an object for field testing");
205 | } catch (SalesforceAuraUnauthenticatedException e) {
206 | logger.error("[!] Cannot continue: authentication is mandatory.");
207 | System.exit(-1);
208 | }
209 | } else {
210 | logger.error("[!] Missing input data for fields tests (recordId or recordType).");
211 | }
212 | } else {
213 | logger.warn("[!] Will test fields on known retrieves objects.");
214 | for (SalesforceSObjectPojo object : objects) {
215 | try {
216 | client.writeToObjectFields(object);
217 | } catch (SalesforceAuraClientBadRequestException e) {
218 | logger.error("[!] Error during API requests.");
219 | System.exit(-1);
220 | } catch (SalesforceAuraMissingRecordIdException e) {
221 | logger.error("[!] Missing recordId for an object for field testing");
222 | } catch (SalesforceAuraUnauthenticatedException e) {
223 | logger.error("[!] Cannot continue: authentication is mandatory.");
224 | System.exit(-1);
225 | }
226 | }
227 | }
228 | }
229 |
230 | // Test create records
231 | } else {
232 | try {
233 | objects = client.createRecords(recordTypesList);
234 |
235 | if (Boolean.parseBoolean(doDump)) {
236 | DumpUtils.dump(objects, output);
237 | }
238 | } catch (SalesforceAuraClientBadRequestException e) {
239 | logger.error("[!] Error during API requests.");
240 | System.exit(-1);
241 | } catch (SalesforceAuraUnauthenticatedException e) {
242 | logger.error("[!] Cannot continue: authentication is mandatory.");
243 | System.exit(-1);
244 | }
245 | }
246 |
247 | logger.info("[*] End of scanning of {}", target);
248 | }
249 | }
--------------------------------------------------------------------------------
/src/main/java/com/cosades/salsa/cache/ObjectFieldCache.java:
--------------------------------------------------------------------------------
1 | package com.cosades.salsa.cache;
2 |
3 | import lombok.Data;
4 | import lombok.NoArgsConstructor;
5 |
6 | import java.util.HashSet;
7 | import java.util.Set;
8 |
9 | @Data
10 | @NoArgsConstructor
11 | public class ObjectFieldCache {
12 | private Set fields = new HashSet<>();
13 |
14 | public Set addFields(final Set newFields) {
15 | fields.addAll(newFields);
16 | return fields;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/cosades/salsa/client/BaseClient.java:
--------------------------------------------------------------------------------
1 | package com.cosades.salsa.client;
2 |
3 | import com.cosades.salsa.configuration.AuraConfiguration;
4 | import com.cosades.salsa.exception.*;
5 | import com.cosades.salsa.pojo.*;
6 | import com.cosades.salsa.utils.AuraHttpUtils;
7 | import com.cosades.salsa.utils.HttpUtils;
8 | import com.cosades.salsa.utils.RESTHTTPUtils;
9 | import org.apache.commons.lang3.StringUtils;
10 | import org.apache.hc.core5.http.ContentType;
11 | import org.apache.hc.core5.http.Header;
12 | import org.apache.hc.core5.http.message.BasicHeader;
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 |
16 | import java.net.URI;
17 | import java.util.LinkedList;
18 | import java.util.List;
19 | import java.util.Set;
20 | import java.util.regex.Matcher;
21 | import java.util.regex.Pattern;
22 |
23 | public abstract class BaseClient {
24 | private static final Logger logger = LoggerFactory.getLogger(BaseClient.class);
25 | protected HttpClient httpClient;
26 | final int MAX_RETRIES = 10;
27 | protected SalesforceAuraCredentialsPojo credentials = new SalesforceAuraCredentialsPojo();
28 | protected String auraAppName = "";
29 | private String auraFwUid = "random";
30 | private final String auraContextMode = "PROD";
31 | protected String auraPath = "";
32 | protected LinkedList auraAppNames = AuraConfiguration.getAuraApps();
33 | private final String DEFAULT_SOAP_PATH = "/services/Soap/c/60.0/";
34 | private final String DEFAULT_SOBJECTS_API_PATH = "/services/data/v60.0/sobjects";
35 | private final String DEFAULT_QUERY_API_PATH = "/services/data/v60.0/query/";
36 |
37 | public void login(final SalesforceAuraCredentialsPojo credentials) throws SalesforceAuraAuthenticationException {
38 | SalesforceAuraMessagePojo[] messagesToComplete = AuraConfiguration.getActionMessageFor("login");
39 |
40 | // For the moment: only one process for login
41 | SalesforceAuraMessagePojo messageToComplete = messagesToComplete[0];
42 | messageToComplete.setParamsValue("username",credentials.getUsername());
43 | messageToComplete.setParamsValue("password",credentials.getPassword());
44 |
45 | SalesforceAuraHttpRequestBodyPojo requestBodyPojo =
46 | new SalesforceAuraHttpRequestBodyPojo(
47 | messageToComplete.getDescriptor(),
48 | messageToComplete.getParams(),
49 | credentials);
50 |
51 | SalesforceAuraHttpResponseBodyPojo salesforceAuraHttpResponseBody;
52 | try {
53 | salesforceAuraHttpResponseBody = this.sendAura(requestBodyPojo);
54 | } catch (SalesforceAuraClientBadRequestException | SalesforceAuraUnauthenticatedException e) {
55 | logger.error("[!] Unable to authenticate: invalid request or invalid credentials.");
56 | throw new SalesforceAuraAuthenticationException();
57 | } catch (SalesforceAuraInvalidParameters e) {
58 | logger.error("[!] Invalid request parameters.", e);
59 | throw new SalesforceAuraAuthenticationException();
60 | }
61 |
62 | // Next step: find SID cookie
63 | if (salesforceAuraHttpResponseBody.getEvents() == null || salesforceAuraHttpResponseBody.getEvents().length == 0) {
64 | logger.error("[!] Unable to authenticate: no event on authentication attempt.");
65 | throw new SalesforceAuraAuthenticationException();
66 | }
67 |
68 | if (salesforceAuraHttpResponseBody.getEvents()[0].getAttributes() == null) {
69 | logger.error("[!] Unable to authenticate: no event attributes on authentication attempt.");
70 | throw new SalesforceAuraAuthenticationException();
71 | }
72 |
73 | String redirectUrl = salesforceAuraHttpResponseBody.getEvents()[0].getAttributes().getValues().get("url");
74 | if (StringUtils.isBlank(redirectUrl)) {
75 | logger.error("[!] Unable to authenticate: invalid redirect URL [{}]", redirectUrl);
76 | throw new SalesforceAuraAuthenticationException();
77 | }
78 |
79 | HttpReponsePojo redirectHttpResponse;
80 | URI redirectURI = URI.create(redirectUrl);
81 | if (!redirectURI.getHost().equals(this.httpClient.getBaseUrl().getHost()) ||
82 | redirectURI.getPort() != this.httpClient.getBaseUrl().getPort()) {
83 | HttpClient temporaryRedirectClient = new HttpClient(this.httpClient, redirectUrl);
84 | redirectHttpResponse = temporaryRedirectClient.get(redirectURI.getRawPath()+"?"+redirectURI.getRawQuery());
85 | } else {
86 | redirectHttpResponse = this.httpClient.get(redirectURI.getRawPath()+"?"+redirectURI.getRawQuery());
87 | }
88 |
89 | String sid = HttpUtils.findCookieFromHttpResponse(redirectHttpResponse, "sid", true);
90 |
91 | if (StringUtils.isBlank(sid)) {
92 | logger.warn("[!] Authentication error: no SID cookie received. Will try without it.");
93 | } else {
94 | this.credentials.setSid(sid);
95 | }
96 |
97 | // Next step: find Salesforce Aura token
98 | HttpReponsePojo responseAuraToken = httpClient.get("/s/");
99 | String token = HttpUtils.findCookieFromHttpResponse(responseAuraToken, "Host-ERIC", false);
100 | if (StringUtils.isBlank(token)) {
101 | logger.error("[!] Unable to authenticate: empty Aura token.");
102 | throw new SalesforceAuraAuthenticationException();
103 | }
104 |
105 | this.credentials.setToken(token);
106 | this.credentials.setUsername(credentials.getUsername());
107 | this.credentials.setPassword(credentials.getPassword());
108 |
109 | // Find app name (maybe not useful)
110 | List appNameHeader = HttpUtils.findHeaders(responseAuraToken, "link");
111 | if (!appNameHeader.isEmpty()) {
112 | String regex = "%40markup%3A%2F%2F([a-zA-Z0-9:%])*?%22%3A%22";
113 | Pattern p = Pattern.compile(regex);
114 | Matcher m = p.matcher(appNameHeader.get(0).getValue());
115 | boolean find = m.find();
116 | if (find) {
117 | String fullString = m.group(0); // ex: %40markup%3A%2F%2Fsiteforce%3AcommunityApp%22%3A%22
118 | this.auraAppName = HttpUtils.urlDecode(fullString.replace("%40markup%3A%2F%2F", "").replace("%22%3A%22",""));
119 | logger.info("[*] Found the app name: {}", this.auraAppName);
120 | } else {
121 | logger.warn("[!] Cannot find the Salesforce Aura app name. Will continue with a default one [{}]", this.auraAppName);
122 | }
123 | }
124 |
125 | logger.info("[*] Login success with credentials [{}]!", this.credentials);
126 | }
127 |
128 | public void updateCredentials(final SalesforceAuraCredentialsPojo credentials) {
129 | this.credentials.setToken(credentials.getToken());
130 | this.credentials.setUsername(credentials.getUsername());
131 | this.credentials.setPassword(credentials.getPassword());
132 | this.credentials.setSid(credentials.getSid());
133 | }
134 |
135 | protected SalesforceAuraHttpResponseBodyPojo sendAura(final SalesforceAuraHttpRequestBodyPojo requestBodyPojo) throws SalesforceAuraClientBadRequestException, SalesforceAuraUnauthenticatedException, SalesforceAuraInvalidParameters {
136 | requestBodyPojo.setFwuid(this.auraFwUid);
137 | requestBodyPojo.setAppName(this.auraAppName);
138 | requestBodyPojo.setMode(this.auraContextMode);
139 | String requestBody = requestBodyPojo.toString();
140 |
141 | int retries = 0;
142 |
143 | SalesforceAuraHttpResponseBodyPojo salesforceAuraHttpResponseBody;
144 |
145 | while(true) {
146 |
147 | if (retries == MAX_RETRIES) {
148 | logger.error("[x] Error on requesting Salesforce Aura target (connection lost?).");
149 | throw new SalesforceAuraClientBadRequestException();
150 | }
151 | if (retries > 0) {
152 | logger.error("[!] Retry ({}/{}) ...", retries, MAX_RETRIES);
153 | }
154 | retries++;
155 |
156 | HttpReponsePojo response = this.httpClient.post(this.auraPath, requestBody, ContentType.APPLICATION_FORM_URLENCODED);
157 | int code = response.getCode();
158 | if (code != 200) {
159 | logger.error("[!] Got an HTTP response code {}.", response.getCode());
160 | logger.debug("[x] Response body: {}", response.getBody());
161 | logger.debug("[x] Request body: {}", requestBody);
162 |
163 | // Special error code 0 is received following an internal problem in Apache HttpClient
164 | if (code == 0) {
165 | this.httpClient = new HttpClient(this.httpClient);
166 | continue;
167 | }
168 |
169 | if (code == 401) {
170 | throw new SalesforceAuraUnauthenticatedException();
171 | }
172 |
173 | // HTTP 404 can occur in specific cases where the sent parameters are incorrect
174 | if (code == 404) {
175 | throw new SalesforceAuraInvalidParameters();
176 | }
177 | }
178 |
179 | // Process the HTTP response
180 | try {
181 | salesforceAuraHttpResponseBody = AuraHttpUtils.parseHttpResponseBody(response.getBody());
182 |
183 | // Once the first request is sent with valid authentication and not desync, the cookie 'sid' can be used
184 | if (StringUtils.isNotBlank(this.credentials.getSid())) {
185 | this.httpClient.addCookie("sid", this.credentials.getSid());
186 | }
187 |
188 | if (salesforceAuraHttpResponseBody != null) {
189 | salesforceAuraHttpResponseBody.setRawBody(response.getBody());
190 | return salesforceAuraHttpResponseBody;
191 | } else {
192 | logger.error("[x] Unable to get a parseable HTTP response.");
193 | }
194 | } catch (SalesforceAuraClientNotSyncException e) {
195 | this.auraFwUid = e.getFwuid();
196 | logger.warn("[!] Client is out-of-sync. Will retry with new FWUID: {}", e.getFwuid());
197 | return this.sendAura(requestBodyPojo);
198 | } catch (SalesforceAuraClientCSRFException e2) {
199 | if (!this.auraAppNames.isEmpty()) {
200 | this.auraAppName = this.auraAppNames.pop();
201 | logger.warn("[!] Site app name is incorrect. Will retry with new app name: {}", this.auraAppName);
202 | return this.sendAura(requestBodyPojo);
203 | } else {
204 | logger.error("[x] Unable to call the target.");
205 | }
206 | }
207 | }
208 | }
209 |
210 | public HttpReponsePojo sendSOAP(final String requestBody) {
211 | Header soapHeader = new BasicHeader("SOAPAction","blank");
212 | return this.httpClient.post(DEFAULT_SOAP_PATH, requestBody, ContentType.TEXT_XML, soapHeader);
213 | }
214 |
215 | public SalesforceRESTSObjectsListHttpResponseBodyPojo sendRESTGetSObjectsList() {
216 | HttpReponsePojo response;
217 | if (StringUtils.isNotBlank(this.credentials.getSid())) {
218 | Header authHeader = new BasicHeader("Authorization","OAuth " + this.credentials.getSid());
219 | response = this.httpClient.get(DEFAULT_SOBJECTS_API_PATH, authHeader);
220 | } else {
221 | response = this.httpClient.get(DEFAULT_SOBJECTS_API_PATH);
222 | }
223 |
224 | return RESTHTTPUtils.parseHttpResponseSObjectsListBody(response.getBody());
225 | }
226 |
227 | public SalesforceSObjectPojo sendRESTGetSObject(final String type, final String id) {
228 |
229 | final String path = DEFAULT_SOBJECTS_API_PATH + "/" + type + "/" + id;
230 |
231 | HttpReponsePojo response;
232 | if (StringUtils.isNotBlank(this.credentials.getSid())) {
233 | Header authHeader = new BasicHeader("Authorization","OAuth " + this.credentials.getSid());
234 | response = this.httpClient.get(path, authHeader);
235 | } else {
236 | response = this.httpClient.get(path);
237 | }
238 |
239 | return RESTHTTPUtils.parseHttpResponseSObjectBody(response.getBody(), type);
240 | }
241 |
242 | public SalesforceRESTSObjectsRecentHttpResponseBodyPojo sendRESTGetSObjectsRecent(final String type) {
243 |
244 | final String path = DEFAULT_SOBJECTS_API_PATH + "/" + type + "/";
245 |
246 | HttpReponsePojo response;
247 | if (StringUtils.isNotBlank(this.credentials.getSid())) {
248 | Header authHeader = new BasicHeader("Authorization","OAuth " + this.credentials.getSid());
249 | response = this.httpClient.get(path, authHeader);
250 | } else {
251 | response = this.httpClient.get(path);
252 | }
253 |
254 | return RESTHTTPUtils.parseHttpResponseSObjectsRecentBody(response.getBody());
255 | }
256 |
257 | protected Set sendRESTGetSObjectDescribeFields(final String type) {
258 | final String path = DEFAULT_SOBJECTS_API_PATH + "/" + type + "/describe";
259 |
260 | HttpReponsePojo response;
261 | if (StringUtils.isNotBlank(this.credentials.getSid())) {
262 | Header authHeader = new BasicHeader("Authorization","OAuth " + this.credentials.getSid());
263 | response = this.httpClient.get(path, authHeader);
264 | } else {
265 | response = this.httpClient.get(path);
266 | }
267 |
268 | return RESTHTTPUtils.parseHttpResponseSObjectDescribeBody(type, response.getBody());
269 | }
270 |
271 | protected Set sendRESTGetSObjectsFromQuery(final String type) {
272 | final String path = DEFAULT_QUERY_API_PATH + "?q=SELECT+FIELDS(ALL)+FROM+"+ type +"+LIMIT+10";
273 |
274 | HttpReponsePojo response;
275 | if (StringUtils.isNotBlank(this.credentials.getSid())) {
276 | Header authHeader = new BasicHeader("Authorization","OAuth " + this.credentials.getSid());
277 | response = this.httpClient.get(path, authHeader);
278 | } else {
279 | response = this.httpClient.get(path);
280 | }
281 |
282 | return RESTHTTPUtils.parseHttpResponseQueryBody(response.getBody(), type);
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/src/main/java/com/cosades/salsa/client/HttpClient.java:
--------------------------------------------------------------------------------
1 | package com.cosades.salsa.client;
2 |
3 | import com.cosades.salsa.exception.HttpClientBadUrlException;
4 | import com.cosades.salsa.pojo.HttpReponsePojo;
5 | import lombok.Getter;
6 | import org.apache.commons.lang3.StringUtils;
7 | import org.apache.hc.client5.http.classic.methods.HttpGet;
8 | import org.apache.hc.client5.http.classic.methods.HttpPost;
9 | import org.apache.hc.client5.http.config.ConnectionConfig;
10 | import org.apache.hc.client5.http.config.RequestConfig;
11 | import org.apache.hc.client5.http.cookie.BasicCookieStore;
12 | import org.apache.hc.client5.http.cookie.CookieStore;
13 | import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
14 | import org.apache.hc.client5.http.impl.classic.HttpClients;
15 | import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
16 | import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
17 | import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
18 | import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
19 | import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
20 | import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
21 | import org.apache.hc.core5.http.ContentType;
22 | import org.apache.hc.core5.http.Header;
23 | import org.apache.hc.core5.http.HttpEntity;
24 | import org.apache.hc.core5.http.HttpHost;
25 | import org.apache.hc.core5.http.config.Registry;
26 | import org.apache.hc.core5.http.config.RegistryBuilder;
27 | import org.apache.hc.core5.http.io.HttpClientResponseHandler;
28 | import org.apache.hc.core5.http.io.entity.EntityUtils;
29 | import org.apache.hc.core5.http.io.entity.StringEntity;
30 | import org.apache.hc.core5.ssl.SSLContexts;
31 | import org.apache.hc.core5.ssl.TrustStrategy;
32 | import org.apache.hc.core5.util.Timeout;
33 | import org.slf4j.Logger;
34 | import org.slf4j.LoggerFactory;
35 |
36 | import javax.net.ssl.SSLContext;
37 | import java.io.IOException;
38 | import java.net.URI;
39 | import java.security.KeyManagementException;
40 | import java.security.KeyStoreException;
41 | import java.security.NoSuchAlgorithmException;
42 |
43 | public class HttpClient {
44 | private static final Logger logger = LoggerFactory.getLogger(HttpClient.class);
45 | private String userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36";
46 | private CookieStore cookieStore = new BasicCookieStore();
47 |
48 | @Getter
49 | private URI baseUrl;
50 | private final RequestConfig requestConfig;
51 |
52 | public HttpClient(final String baseUrl,
53 | final String userAgent,
54 | final String proxyHost,
55 | final int proxyPort) throws HttpClientBadUrlException {
56 |
57 | if (!baseUrl.startsWith("http://") && !baseUrl.startsWith("https://")) {
58 | throw new HttpClientBadUrlException("Target URL is not HTTP/HTTPS scheme");
59 | }
60 |
61 | this.baseUrl = URI.create(baseUrl);
62 | // Set proxy
63 | if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0 && proxyPort < 65535) {
64 | HttpHost proxy = new HttpHost(proxyHost, proxyPort);
65 | this.requestConfig = RequestConfig.custom()
66 | .setProxy(proxy)
67 | .build();
68 | } else {
69 | this.requestConfig = RequestConfig.custom()
70 | .build();
71 | }
72 | // Set User-Agent
73 | if (StringUtils.isNotBlank(userAgent)) {
74 | this.userAgent = userAgent;
75 | }
76 | }
77 |
78 | /**
79 | * Recreate a new HTTPClient from another one
80 | * @param httpClient old HttpClient
81 | */
82 | public HttpClient(HttpClient httpClient) {
83 | this.baseUrl = httpClient.getBaseUrl();
84 | this.userAgent = httpClient.userAgent;
85 | this.requestConfig = httpClient.requestConfig;
86 | this.cookieStore = httpClient.cookieStore;
87 | }
88 |
89 | private CloseableHttpClient createHttpClient() {
90 | final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
91 | final SSLContext sslContext;
92 | try {
93 | sslContext = SSLContexts.custom()
94 | .loadTrustMaterial(null, acceptingTrustStrategy)
95 | .build();
96 | } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
97 | throw new RuntimeException(e);
98 | }
99 | final SSLConnectionSocketFactory sslsf =
100 | new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
101 | final Registry socketFactoryRegistry =
102 | RegistryBuilder. create()
103 | .register("https", sslsf)
104 | .register("http", new PlainConnectionSocketFactory())
105 | .build();
106 |
107 | final BasicHttpClientConnectionManager connectionManager =
108 | new BasicHttpClientConnectionManager(socketFactoryRegistry);
109 | connectionManager.setConnectionConfig(ConnectionConfig.custom()
110 | .setSocketTimeout(Timeout.ofSeconds(120))
111 | .setConnectTimeout(Timeout.ofSeconds(120))
112 | .build());
113 |
114 | return HttpClients.custom()
115 | .setConnectionManager(connectionManager)
116 | .setDefaultCookieStore(cookieStore)
117 | .build();
118 | }
119 |
120 | /**
121 | * Create new HttpClient based on another one, when the main host can be different
122 | * @param httpClient
123 | * @param redirectUrl
124 | */
125 | public HttpClient(HttpClient httpClient, String redirectUrl) {
126 | this(httpClient);
127 | this.baseUrl = URI.create(redirectUrl);
128 | }
129 |
130 | public HttpReponsePojo post(final String uri) {
131 | return this.post(uri, "", ContentType.APPLICATION_FORM_URLENCODED);
132 | }
133 |
134 | public HttpReponsePojo post(final String uri, final String requestJsonBody, final ContentType contentType, final Header ... headers) {
135 |
136 | URI finalUrl = URI.create(this.baseUrl.toString() + uri);
137 |
138 | HttpPost request = new HttpPost(finalUrl);
139 | final StringEntity requestEntity = new StringEntity(requestJsonBody);
140 | request.setEntity(requestEntity);
141 | request.setHeader("Accept", "*/*");
142 | request.setHeader("Accept-Language", "en");
143 | request.setHeader("Content-type", contentType.getMimeType());
144 | request.setHeader("User-Agent", this.userAgent);
145 | for (Header h : headers) {
146 | request.setHeader(h);
147 | }
148 |
149 | if (requestConfig != null) {
150 | request.setConfig(requestConfig);
151 | }
152 |
153 | HttpClientResponseHandler responseHandler = response -> {
154 | HttpEntity entity = response.getEntity();
155 |
156 | return new HttpReponsePojo(EntityUtils.toString(entity), response.getCode(), response.getHeaders());
157 | };
158 |
159 | try (CloseableHttpClient httpClient = this.createHttpClient()){
160 | return httpClient.execute(request, responseHandler);
161 | } catch (IOException e) {
162 | logger.error("[!] Error on POST request to {}", uri, e);
163 | return new HttpReponsePojo();
164 | }
165 | }
166 |
167 | public HttpReponsePojo get(final String uri, final Header ... headers) {
168 | URI finalUrl = URI.create(this.baseUrl.toString() + uri);
169 |
170 | HttpGet request = new HttpGet(finalUrl);
171 | request.setHeader("Accept", "*/*");
172 | request.setHeader("Accept-Language", "en");
173 | request.setHeader("User-Agent", this.userAgent);
174 | for (Header h : headers) {
175 | request.setHeader(h);
176 | }
177 |
178 | if (requestConfig != null) {
179 | request.setConfig(requestConfig);
180 | }
181 |
182 | HttpClientResponseHandler responseHandler = response -> {
183 | HttpEntity entity = response.getEntity();
184 | return new HttpReponsePojo(EntityUtils.toString(entity), response.getCode(), response.getHeaders());
185 | };
186 |
187 | try (CloseableHttpClient httpClient = this.createHttpClient()){
188 | return httpClient.execute(request, responseHandler);
189 | } catch (IOException e) {
190 | logger.error("[!] Error on GET request to {}", uri, e);
191 | return new HttpReponsePojo();
192 | }
193 | }
194 |
195 | public void addCookie(final String name, final String value) {
196 | BasicClientCookie cookie = new BasicClientCookie(name, value);
197 | cookie.setDomain(this.baseUrl.getHost());
198 | cookie.setPath(this.baseUrl.getPath());
199 | if (this.cookieStore.getCookies().stream().noneMatch(c -> name.equals(c.getName()))) {
200 | this.cookieStore.addCookie(cookie);
201 | }
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/src/main/java/com/cosades/salsa/configuration/AuraConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.cosades.salsa.configuration;
2 |
3 | import com.cosades.salsa.pojo.SalesforceAuraMessagePojo;
4 | import com.fasterxml.jackson.databind.ObjectMapper;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import java.io.BufferedReader;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 | import java.io.InputStreamReader;
12 | import java.util.ArrayList;
13 | import java.util.LinkedList;
14 | import java.util.List;
15 | import java.util.Properties;
16 | import java.util.regex.Pattern;
17 |
18 | public abstract class AuraConfiguration {
19 | private static final Logger logger = LoggerFactory.getLogger(AuraConfiguration.class);
20 | private static final List AURA_URIS;
21 | private static final LinkedList AURA_APPS;
22 | private static final Properties AURA_MISC_PROPERTIES;
23 |
24 | static {
25 | String AURA_URIS_FILENAME = "salesforce-aura-uris.txt";
26 | AURA_URIS = readSimpleFile(AURA_URIS_FILENAME);
27 | String AURA_APPS_FILENAME = "salesforce-aura-apps.txt";
28 | AURA_APPS = new LinkedList<>(readSimpleFile(AURA_APPS_FILENAME));
29 | String AURA_MISC_FILENAME = "salesforce-aura-misc.properties";
30 | AURA_MISC_PROPERTIES = loadConfig(AURA_MISC_FILENAME);
31 | }
32 |
33 | public static List getAuraUris() {
34 | return AURA_URIS;
35 | }
36 |
37 | public static LinkedList getAuraApps() {
38 | return AURA_APPS;
39 | }
40 |
41 | public static Pattern getAuraRegex() {
42 | return Pattern.compile(AURA_MISC_PROPERTIES.getProperty("regex"),Pattern.MULTILINE);
43 | }
44 |
45 | public static SalesforceAuraMessagePojo[] getActionMessageFor(final String actionNameFromFilename) {
46 | String filename = "salesforce-aura-actions-"+actionNameFromFilename+".json";
47 | try (InputStream input = AuraConfiguration.class.getClassLoader().getResourceAsStream(filename)) {
48 | if (input == null) {
49 | logger.error("[!] Cannot find the filename {}", filename);
50 | System.exit(-1);
51 | }
52 |
53 | ObjectMapper objectMapper = new ObjectMapper();
54 | try (BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
55 | return objectMapper.readValue(reader, SalesforceAuraMessagePojo[].class);
56 | }
57 |
58 | } catch (IOException e) {
59 | logger.error("[!] Error at reading the file {}", filename, e);
60 | System.exit(-1);
61 | }
62 | return null;
63 | }
64 |
65 | private static Properties loadConfig(String filename) {
66 | Properties properties = new Properties();
67 | try (InputStream input = AuraConfiguration.class.getClassLoader().getResourceAsStream(filename)) {
68 | if (input == null) {
69 | logger.error("[!] Cannot find the filename {}", filename);
70 | return null;
71 | }
72 | properties.load(input);
73 |
74 | } catch (IOException ex) {
75 | logger.error("[!] Error at reading properties filename {}", filename, ex);
76 | return null;
77 | }
78 |
79 | return properties;
80 | }
81 |
82 | public static List readSimpleFile(final String filename) {
83 | List lines = new ArrayList<>();
84 | try (InputStream input = AuraConfiguration.class.getClassLoader().getResourceAsStream(filename)) {
85 | if (input == null) {
86 | logger.error("[!] Cannot find the filename {}", filename);
87 | System.exit(-1);
88 | }
89 |
90 | try (BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
91 | String line;
92 | while ((line = reader.readLine()) != null) {
93 | lines.add(line);
94 | }
95 | }
96 |
97 | } catch (IOException e) {
98 | logger.error("[!] Error at reading text filename {}", filename, e);
99 | System.exit(-1);
100 | }
101 |
102 | return lines;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/com/cosades/salsa/configuration/SalesforceSObjectsConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.cosades.salsa.configuration;
2 |
3 | import com.cosades.salsa.pojo.SalesforceSObjectFieldPojo;
4 | import com.cosades.salsa.pojo.SalesforceSObjectPojo;
5 | import com.nawforce.runforce.System.SObject;
6 | import org.apache.commons.lang3.StringUtils;
7 | import org.objenesis.Objenesis;
8 | import org.objenesis.ObjenesisStd;
9 | import org.objenesis.instantiator.ObjectInstantiator;
10 | import org.reflections.Reflections;
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import java.lang.reflect.Field;
15 | import java.util.HashSet;
16 | import java.util.List;
17 | import java.util.Optional;
18 | import java.util.Set;
19 |
20 | public abstract class SalesforceSObjectsConfiguration {
21 | private static final Logger logger = LoggerFactory.getLogger(SalesforceSObjectsConfiguration.class);
22 | private static Set sObjects;
23 | private static final String SOBJECTNAMES_WORDLIST_FILENAME = "salesforce-aura-objects.txt";
24 | public static final String SOBJECTS_PACKAGE_NAME = "com.nawforce.runforce.SObjects";
25 |
26 | public static void init() {
27 | if (sObjects == null) {
28 | logger.debug("[x] Building sObjects classes and fields through reflection ...");
29 | Set> sobjectClasses =
30 | findAllClassesFromPackage();
31 | sObjects = buildFromClasses(sobjectClasses);
32 | logger.info("[*] Found {} object types from introspection.", sObjects.size());
33 | logger.debug("[x] Found following object types from introspection: {}", sObjects);
34 | }
35 | }
36 |
37 | public static SalesforceSObjectPojo getSObject(final String sObjectType) {
38 | if (StringUtils.isBlank(sObjectType)) {
39 | logger.error("[!] Cannot find sObject class from unspecified type.");
40 | }
41 | if (sObjects == null) {
42 | init();
43 | }
44 | logger.debug("[x] Search for sObject class from type {}", sObjectType);
45 | Optional object = sObjects.stream().filter(sObject -> sObjectType.equalsIgnoreCase(sObject.getSObjectType())).findFirst();
46 | if (object.isPresent()) {
47 | logger.debug("[x] Found sObject class from type {}", sObjectType);
48 | return object.get();
49 | }
50 | logger.debug("[x] sObject class not found from type {}", sObjectType);
51 | return null;
52 | }
53 |
54 | public static Set getSObjects() {
55 | if (sObjects == null) {
56 | init();
57 | }
58 | return sObjects;
59 | }
60 |
61 | private static Set> findAllClassesFromPackage() {
62 | Reflections reflections = new Reflections(SalesforceSObjectsConfiguration.SOBJECTS_PACKAGE_NAME);
63 | Set> classes = reflections.getSubTypesOf(SObject.class);
64 | return classes;
65 | }
66 |
67 | private static Set buildFromClasses(final Set> sobjectClasses) {
68 | Set objects = new HashSet<>();
69 | for (Class extends SObject> sObjectClass : sobjectClasses) {
70 | SalesforceSObjectPojo objectPojo = buildFromClass(sObjectClass, sobjectClasses, false);
71 | objects.add(objectPojo);
72 | }
73 | return objects;
74 | }
75 |
76 | private static SalesforceSObjectPojo buildFromClass(final Class extends SObject> sObjectClass,
77 | final Set> sobjectClasses,
78 | final boolean isAttribute) {
79 |
80 | SalesforceSObjectPojo objectPojo = new SalesforceSObjectPojo();
81 | Field[] fields = sObjectClass.getDeclaredFields();
82 | for (Field f : fields) {
83 | String fieldName = f.getName();
84 |
85 | boolean localIsArray = f.getType().isArray();
86 | Class fieldClass;
87 | if (!localIsArray) {
88 | fieldClass = f.getType();
89 | } else {
90 | fieldClass = f.getType().getComponentType();
91 | }
92 |
93 | if (!"Fields".equalsIgnoreCase(f.getName())) {
94 | if (sobjectClasses.contains(fieldClass)) {
95 |
96 | if (localIsArray) {
97 | SalesforceSObjectFieldPojo newField = new SalesforceSObjectFieldPojo<>();
98 |
99 | newField.setName(fieldName);
100 | SalesforceSObjectPojo[] values = new SalesforceSObjectPojo[1];
101 | SalesforceSObjectPojo value;
102 | if (!isAttribute) {
103 | value = buildFromClass(fieldClass, sobjectClasses, true);
104 | values[0] = value;
105 | }
106 | newField.setValue(values);
107 | objectPojo.getFields().add(newField);
108 | } else {
109 | SalesforceSObjectFieldPojo newField = new SalesforceSObjectFieldPojo<>();
110 | newField.setName(fieldName);
111 | // To avoid recursive and infinite loop: limit to first attribute for subclass resolving
112 | if (!isAttribute) {
113 | newField.setValue(buildFromClass(fieldClass, sobjectClasses, true));
114 | objectPojo.getFields().add(newField);
115 | } else {
116 | newField.setValue(new SalesforceSObjectPojo());
117 | objectPojo.getFields().add(newField);
118 | }
119 | }
120 | } else {
121 |
122 | if ("SObjectType".equalsIgnoreCase(fieldName)) {
123 | SalesforceSObjectFieldPojo newField = new SalesforceSObjectFieldPojo<>();
124 | newField.setName(fieldName);
125 | String className = sObjectClass.getSimpleName();
126 | newField.setValue(className);
127 | objectPojo.getFields().add(newField);
128 | } else {
129 | SalesforceSObjectFieldPojo