Skip to content

=> ERROR [11/20] RUN ./update-agents.sh #2579

@jt0dd

Description

@jt0dd

Describe the bug

./update-agents.sh is missing and we don't see it in the original repo / are confused where it's supposed to come from.

PS C:\Users\jonat\Documents\GitHub\hunt\caldera> docker build . -t caldera:server
[+] Building 20.2s (15/24)
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                0.0s
 => => transferring dockerfile: 2.22kB                                                                                                                                                                                                                                                              0.0s 
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                   0.1s 
 => => transferring context: 356B                                                                                                                                                                                                                                                                   0.0s 
 => [internal] load metadata for docker.io/library/ubuntu:focal                                                                                                                                                                                                                                     1.6s 
 => [ 1/20] FROM docker.io/library/ubuntu:focal@sha256:47f14534bda344d9fe6ffd6effb95eefe579f4be0d508b7445cf77f61a0e5724                                                                                                                                                                             0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                   0.6s 
 => => transferring context: 68.71MB                                                                                                                                                                                                                                                                0.6s 
 => CACHED [ 2/20] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime &&     echo UTC > /etc/timezone                                                                                                                                                                                               0.0s
 => CACHED [ 3/20] WORKDIR /usr/src/app                                                                                                                                                                                                                                                             0.0s 
 => CACHED [ 4/20] RUN apt-get update &&     apt-get -y install python3 python3-pip golang git                                                                                                                                                                                                      0.0s 
 => CACHED [ 5/20] RUN if [ "false" = "true" ] ; then apt-get -y install mingw-w64; fi                                                                                                                                                                                                              0.0s 
 => CACHED [ 6/20] ADD requirements.txt .                                                                                                                                                                                                                                                           0.0s 
 => CACHED [ 7/20] RUN pip3 install --no-cache-dir -r requirements.txt                                                                                                                                                                                                                              0.0s 
 => [ 8/20] ADD . .                                                                                                                                                                                                                                                                                 1.3s
 => [ 9/20] RUN go get github.com/grandcat/zeroconf                  github.com/google/go-github/github            github.com/grandcat/zeroconf                  github.com/miekg/dns                          golang.org/x/oauth2                           gopkg.in/natefinch/npipe.v2           15.9s
 => [10/20] WORKDIR /usr/src/app/plugins/sandcat                                                                                                                                                                                                                                                    0.1s
 => ERROR [11/20] RUN ./update-agents.sh                                                                                                                                                                                                                                                            0.4s
------
 > [11/20] RUN ./update-agents.sh:
#15 0.348 /bin/sh: 1: ./update-agents.sh: not found

I'm aware of this issue: #2515

Where the response is:

"If you created/edited your .sh script file in Windows, make sure it was saved with line ending in Unix format."

But there doesn't appear to be any .sh script in the Caldera repo to begin with, so I'm not sure where this file is supposed to come from.

Edit: I see, Dockerfile changes working directory to /usr/src/app then copies all contents from caldera into there, which means /usr/src/app/plugins/sandcat exists, and Docker changes the working directory to that. We do not edit the script, and it is there, so it still shouldn't have to do with windows line ending format.

Edit 2: Ok we did some debugging, ended the build process early and just used CMD cat update-agents.sh to verify the contents, which do exist:

img

Edit 3: We figured out a fix. We are not editing this file on Windows, we're cloning it straight from the repo, so clearly some automated part of the standard documented clone / install is damaging the line endings:

...
# Update default sandcat agent binaries
WORKDIR /usr/src/app/plugins/sandcat

RUN cp update-agents.sh update-agents-copy.sh
RUN tr -d '\15\32' < update-agents-copy.sh > update-agents.sh
RUN ./update-agents.sh

...

and then we ran into the error you guys are fixing here 2c990da so we made those same changes.

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/mitre/caldera.git --recursive --branch 4.0.0-beta
  2. cd caldera
  3. docker build . -t caldera:server

Expected behavior
Working Docker container for Caldera.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11 Pro
  • Browser: Chrome

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorno-issue-activityNeeds Attention

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions