Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aws
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
aws
Commits
576c77ac
Commit
576c77ac
authored
Aug 18, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
50a738dd
Pipeline
#212
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
app.js
app.js
+13
-7
No files found.
app.js
View file @
576c77ac
...
...
@@ -11,19 +11,25 @@ if (!fs.existsSync(rootKeyFilePath)) {
process
.
exit
(
1
);
}
// Function to
extract AWS credentials using regex
// Function to
read the second line and extract AWS credentials
function
extractAWSCredentials
(
filePath
)
{
const
fileContent
=
fs
.
readFileSync
(
filePath
,
'
utf8
'
);
const
accessKeyIdMatch
=
fileContent
.
match
(
/Access key ID
\s
*,
\s
*
([^
,
\s]
+
)
/i
);
const
secretAccessKeyMatch
=
fileContent
.
match
(
/Secret access key
\s
*,
\s
*
([^
,
\s]
+
)
/i
);
const
lines
=
fileContent
.
split
(
'
\n
'
);
if
(
accessKeyIdMatch
&&
secretAccessKeyMatch
)
{
if
(
lines
.
length
<
2
)
{
throw
new
Error
(
'
The rootkey.csv file does not contain enough lines.
'
);
}
const
secondLine
=
lines
[
1
].
trim
();
const
[
accessKeyId
,
secretAccessKey
]
=
secondLine
.
split
(
'
,
'
);
if
(
accessKeyId
&&
secretAccessKey
)
{
return
{
accessKeyId
:
accessKeyId
Match
[
1
]
,
secretAccessKey
:
secretAccessKey
Match
[
1
]
,
accessKeyId
:
accessKeyId
.
trim
()
,
secretAccessKey
:
secretAccessKey
.
trim
()
,
};
}
else
{
throw
new
Error
(
'
Failed to extract AWS credentials from rootkey.csv
'
);
throw
new
Error
(
'
Failed to extract AWS credentials from
the second line of
rootkey.csv
'
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment