Skip to content

fix: request to mask variables by taskLogger #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ RUN yarn install --frozen-lockfile --production

FROM base AS production
COPY --from=prod-dependencies /root/cf-runtime/node_modules ./node_modules
COPY --from=build /root/cf-runtime/dist ./dist
COPY . .
COPY --from=build /root/cf-runtime/dist ./lib

#purpose of security
RUN npm -g uninstall npm

USER cfu
CMD ["node", "dist/index.js"]
CMD ["node", "lib/index.js"]
2 changes: 1 addition & 1 deletion lib/forever.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
while ($true) {
Start-Sleep -s 1
& node dist/index.js
& node lib/index.js
}
9 changes: 6 additions & 3 deletions lib/http-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class HttpServer {
private readonly port;
private readonly server;

constructor(private taskLogger: any) {
constructor(private taskLogger?: any) {
try {
this.host = process.env.HOST || '0.0.0.0';
this.port = +(process.env.PORT || 8080);
Expand All @@ -28,6 +28,10 @@ export class HttpServer {
}
}

setTaskLogger(taskLogger: any) {
this.taskLogger = taskLogger;
}

private initSecrets() {
const secretsOptions = {
schema: {
Expand All @@ -44,8 +48,7 @@ export class HttpServer {

this.server.post('/secrets', secretsOptions, async (request, reply) => {
try {
const { body }: { body: any } = request;
const { secret } = body;
const { body: secret }: { body: any } = request;
logger.info(`got request to add new mask: ${secret.key}`);
this.taskLogger.addNewMask(secret);
reply.code(201);
Expand Down
2 changes: 1 addition & 1 deletion lib/isReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function isContainerLoggerReady(state) {

(() => {
const containerId = process.argv[2];
const state = JSON.parse(readFileSync('./dist/state.json').toString('utf-8'));
const state = JSON.parse(readFileSync('./lib/state.json').toString('utf-8'));
let isReady = false;
if (containerId) {
isReady = isContainerReady(state, containerId);
Expand Down
4 changes: 2 additions & 2 deletions lib/isReady.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $CONTAINER_ID=$args[0]

if ( $CONTAINER_ID ) {
echo "checking if container:$CONTAINER_ID exists"
if (select-string -Pattern $CONTAINER_ID -Path ./dist/state.json) {
if (select-string -Pattern $CONTAINER_ID -Path ./lib/state.json) {
echo "container $CONTAINER_ID is ready"
Exit 0
} else {
Expand All @@ -15,7 +15,7 @@ if ( $CONTAINER_ID ) {
}
} else {
echo "checking if container logger is ready"
if (select-string -Pattern "ready" -Path ./dist/state.json) {
if (select-string -Pattern "ready" -Path ./lib/state.json) {
echo "ready"
Exit 0
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/isReady.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ CONTAINER_ID=$1

if [ -n "$CONTAINER_ID" ]; then
echo "checking if container: $CONTAINER_ID exists"
grep -q $CONTAINER_ID ./dist/state.json
grep -q $CONTAINER_ID ./lib/state.json
else
echo "checking if container logger is ready"
grep -q "ready" ./dist/state.json
grep -q "ready" ./lib/state.json
fi


1 change: 1 addition & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Logger {
TaskLogger(this.taskLoggerConfig.task, { ...this.taskLoggerConfig.opts, updateLogsRate: true })
.then((taskLogger) => {
this.taskLogger = taskLogger;
this.httpServer.setTaskLogger(taskLogger);
taskLogger.on('error', (err) => {
logger.error(err.stack);
});
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"test:ci": "yarn test",
"start": "node dist/index.js",
"version": "exit 0",
"build": "rm -rf dist && tsc -p tsconfig.json"
"build": "rm -rf dist && tsc -p tsconfig.json && yarn run build:copy-scripts",
"build:copy-scripts": "cp ./lib/*.sh ./lib/*.ps1 ./dist"
}
}
2 changes: 1 addition & 1 deletion service.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 1.12.1
version: 1.12.2
Loading